1、打开apache的Server Status页面,在httpd.conf文件最下边加入代码段。
ExtendedStatus On
<location /server-status>
SetHandler server-status
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
</location>
2、通过脚本获取zabbix需要的item的值,在/alidata/zabbix-agentd/scripts/目录下写个脚本apache_status.sh
#!/bin/bash if [[ "$1" = "Workers" ]]; then wget --quiet -O - http://127.0.0.1/server-status?auto | grep Score | grep -o "\." | wc -l else wget --quiet -O - http://127.0.0.1/server-status?auto | head -n 9 | grep $1 | awk -F ":" '{print $2}' fi
3、修改zabbix的配置文件/usr/local/zabbix-agentd/etc/zabbix_agentd.conf,添加
UserParameter=apache[*],bash /alidata/zabbix-agentd/scripts/apache_status.sh $1
4、重启zabbix的客户端
转载于:https://blog.51cto.com/drinkboy/1692425