监控HTTPD端口的shell
#!/bin/bash
#2019年4月19日18::
#######
httpd=` netstat -tnlp|grep httpd|awk '{print $4}'|sed 's/://g'`
port=($httpd)
printf '{'
printf '"data":['
for key in ${!port[@]}
do
if [[ "${#port[@]}" -gt && $key -ne "$((${#port[@]}-1))" ]];then
printf '{'
printf "\"{#HTTPDPORT}\":\"${port[${key}]}\"},"
else [[ "${key}" -eq "$((${#port[@]} -1))" ]]
printf '{'
printf "\"{#HTTPDPROT}\":\"${port[${key}]}\"}"
fi
done
printf ']'
printf '}'
~
在agent添加如下代码
vim /etc/zabbix/zabbix_agentd.conf
UserParameter=httpd.discovery[*],/data/sh/discovery_httpd.sh $
UserParameter=httpd.status[*], netstat -tnlp|grep -c $