zabbix监控nginx连接数量
#!/bin/bash
conn=`netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a,S[a]}' | grep "ESTABLISHED" | awk '{print $2}'`
if [ $conn -le 1000 ]
then
echo 1
else
echo 0
fi
#vi ../etc/zabbix_agentd.conf
UserParameter=conn_nginx,bash /soft/zabbix_agent/scripts/conn_now
zabbix-server测试
zabbix_get -s 172.30.224.28 -p 9222 -k "conn_nginx"