前面介紹了zabbix3.0.3環境及相關監控項的添加,下面介紹下針對apache的監控配置:
1)在apache配置文件中打開server-status狀態訪問功能(自帶的)apache
[root@IDC-Admin-01 ~]# /data/apache/bin/httpd -v Server version: Apache/2.4.25 (Unix) Server built: Jun 19 2017 19:18:00 [root@IDC-Admin-01 ~]# cat /data/apache/conf/httpd.conf|grep status //確保apache支持status查詢功能 LoadModule status_module modules/mod_status.so [root@IDC-Admin-01 ~]# cat /data/apache/conf/httpd.conf|grep httpd-info.conf Include conf/extra/httpd-info.conf //打開這一行的註釋 [root@IDC-Admin-01 ~]# cat /data/apache/conf/extra/httpd-info.conf ......... <Location /server-status> SetHandler server-status Order deny,allow Allow from all </Location> # # ExtendedStatus controls whether Apache will generate "full" status # information (ExtendedStatus On) or just basic information (ExtendedStatus # Off) when the "server-status" handler is called. The default is Off. # ExtendedStatus On [root@IDC-Admin-01 ~]# /data/apache/bin/httpd -k restart //重啓apache服務 而後就能夠訪問apache的狀態頁面了 [root@IDC-Admin-01 ~]# curl http://localhost/server-status [root@IDC-Admin-01 ~]# curl http://localhost/server-status?auto localhost ServerVersion: Apache/2.4.25 (Unix) OpenSSL/1.0.2l PHP/5.6.30 ServerMPM: event ........... ConnsTotal: 2 ConnsAsyncWriting: 0 ConnsAsyncKeepAlive: 1 ConnsAsyncClosing: 1 Scoreboard: ___________________________________________________________________________________________W________............................................................................................................................................................................................................................................................................................................ TLSSessionCacheStatus CacheType: SHMCB CacheSharedMemory: 512000 CacheCurrentEntries: 6 .......
2)編寫apache狀態監控腳本bash
[root@IDC-Admin-01 ~]# ll /data/zabbix/monitor_scripts/zapache.sh -rwxr-xr-x 1 zabbix zabbix 6.0K 6月 25 01:47 /data/zabbix/monitor_scripts/zapache.sh [root@IDC-Admin-01 ~]# cat /data/zabbix/etc/zabbix_agentd.conf|grep Include ### Option: Include Include=/data/zabbix/etc/zabbix_agentd.conf.d/ [root@IDC-Admin-01 ~]# cat /data/zabbix/etc/zabbix_agentd.conf.d/userparameter_zapache.conf # # This is a sample zabbix_agentd config file. # Put it to /etc/zabbix_agentd.conf.d or otherwise integrate into agent config. # Edit to your needs. # UserParameter=zapache[*],/data/zabbix/monitor_scripts/zapache.sh \$1 [root@IDC-Admin-01 ~]# /etc/init.d/zabbix_agentd restart
apache腳本和監控模塊下載地址:https://pan.baidu.com/s/1eRBKEcE (提取密碼:nxs5)curl
3)在zabbix界面裏導入apache監控模塊ui
接着在「主機」的模塊裏添加apache模塊(對應模塊的監控圖形能夠本身根據須要進行添加或移除)url
點擊「添加」,就能看到該監控項的全部圖形了。spa