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的客戶端