tcp连接数监控可用于存储维护中前端业务访问量的统计:使用命令netstat -anp
Proto:表示协议类型,Recv-Q:表示收包数量, Send-Q:表示发包数量
实战示例:
#!/bin/bash #this script is used for count the quantity of session overstock log=/ap/log/session_overstock_count.log log_tmp=/ap/log/session_overstock_tmp.log if [ ! -d "/ap/log" ];then mkdir -p /ap/log fi netstat -anp | grep 2049 | grep "ESTABLISHED" | awk '{print $2}' > $log_tmp sum=0 for i in `cat $log_tmp`;do let sum=sum+i done echo "`date +%Y-%m-%d-%H:%M:%S` $sum" >> $log /opt/product/zabbix/bin/zabbix_sender -c /opt/product/zabbix/conf/zabbix_agentd.conf -k "session_overstock_num" -o "$sum"
标签:tmp,shell,log,sum,tcp,ap,zabbix,连接数,overstock From: https://www.cnblogs.com/Albert-M/p/17671722.html