mkdir /etc/zabbix/scripts
1.编写监控tcp连接数的shell脚本,并添加执行权限
cat /etc/zabbix/scripts/tcp_status.sh
#!/bin/bash
[ $# -ne 1 ] && echo “Usage:CLOSE-WAIT|CLOSED|CLOSING|ESTAB|FIN-WAIT-1|FIN-WAIT-2|LAST-ACK|LISTEN|SYN-RECV SYN-SENT|TIME-WAIT” && exit 1
tcp_status_fun(){
TCP_STAT=KaTeX parse error: Expected 'EOF', got '#' at position 3: 1 #̲netstat -n | aw…NF]} END {for(key in state) print key,state[key]}’ > /tmp/netstat.tmp
ss -ant | awk 'NR>1 {++s[KaTeX parse error: Expected 'EOF', got '}' at position 3: 1]}̲ END {for(k in …(grep “$TCP_STAT” /tmp/ss.tmp | cut -d ’ ’ -f2)
if [ -z $TCP_STAT_VALUE ];then
TCP_STAT_VALUE=0
fi
echo $TCP_STAT_VALUE
}
tcp_status_fun $1
添加执行权限&