您好,登錄后才能下訂單哦!
一、開啟php-fpm的status頁面,此頁面跟nginx的stub_status頁面類似,記錄著php運行狀態信息
# cat /etc/php-fpm.d/www.conf pm.status_path = /status
二、配置nginx代理訪問php的status頁面
# cat /etc/nginx/conf.d/nginx_status.conf server { listen 80 default ; server_name _ ; location = /status { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi.conf; \\此選項必須添加,不添加采集不到數據 access_log off; allow 127.0.0.1; deny all ; }
三、訪問測試,確保可以訪問到php的status的頁面數據
# curl http://127.0.0.1/status pool: www process manager: dynamic start time: 31/3月/2016:22:29:27 +0800 start since: 489290 accepted conn: 3 listen queue: 0 max listen queue: 0 listen queue len: 128 idle processes: 4 active processes: 1 total processes: 5 max active processes: 1 max children reached: 0
四、在agent端編寫shell腳本,采集php的status頁面信息;腳本路徑存放在/opt/zabbix/script/目錄下
# vim php_fpm_status.sh #!/bin/bash AcceptedConn(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/accepted conn/{print $2}' |awk '{print $1}' } ListenQueue(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/listen queue/{print $2}' |awk '{print $1}' } MaxListenQueue(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/max listen queue/{print $2}' |awk '{print $1}' } ListenQueueLen(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/listen queue len/{print $2}'|awk '{print $1}' } IdleProcesses(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/idle processes/{print $2}'|awk '{print $1}' } ActiveProcesses(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/active processes/{print $2}'|awk '{print $1}' } TotalProcesses(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/total processes/{print $2}'|awk '{print $1}' } MaxActiveProcesses(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/max active processes/{print $2}' |awk '{print $1}' } MaxChildrenReached(){ curl http://127.0.0.1/zphp_status 2>/dev/null | awk -F ":" '/max children reached/{print $2}' |awk '{print $1}' } $1 # chmod +x php_fpm_status.sh \\添加執行權限
五、在agent端,創建key、value;位置在opt/zabbix/etc/zabbix_agentd.conf.d/目錄下
# vim php-fpm-nginx.conf UserParameter=active.conn, /opt/zabbix/script/php_fpm_status.sh AcceptedConn UserParameter=listen.queue, /opt/zabbix/script/php_fpm_status.sh ListenQueue UserParameter=max.listen.queue, /opt/zabbix/script/php_fpm_status.sh MaxListenQueue UserParameter=listen.queue.len,/opt/zabbix/script/php_fpm_status.sh ListenQueueLen UserParameter=idle.processes, /opt/zabbix/script/php_fpm_status.sh IdleProcesses UserParameter=active.processes, /opt/zabbix/script/php_fpm_status.sh ActiveProcesses UserParameter=total.processes, /opt/zabbix/script/php_fpm_status.sh TotalProcesses UserParameter=max.active.processes, /opt/zabbix/script/php_fpm_status.sh MaxActiveProcesses UserParameter=max.children.reached, /opt/zabbix/script/php_fpm_status.sh MaxChildrenReached # /etc/init.d/zabbix_agentd restart \\上述配置完成后,重啟agentd服務
六、在server端利用zabbix_get獲取測試數據,查看配置是否成功
# zabbix_get -s 172.16.100.17 -p 10050 -k "active.conn" 42
七、以上操作成功后,在zabbix的web頁面創建php模板
1)創建模板
2)創建應用集
3)創建項目
4)創建圖形
5)將此模板關聯主機,查看獲取的數據
到此,可以安心的邊喝茶邊觀察php的狀態了。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。