zabbix監(jiān)控php狀態(tài)
創(chuàng)新互聯(lián)公司專注于白山網(wǎng)站建設(shè)服務(wù)及定制,我們擁有豐富的企業(yè)做網(wǎng)站經(jīng)驗。 熱誠為您提供白山營銷型網(wǎng)站建設(shè),白山網(wǎng)站制作、白山網(wǎng)頁設(shè)計、白山網(wǎng)站官網(wǎng)定制、重慶小程序開發(fā)服務(wù),打造白山網(wǎng)絡(luò)公司原創(chuàng)品牌,更為您提供白山網(wǎng)站排名全網(wǎng)營銷落地服務(wù)。
通過nginx調(diào)用php-fpm來查詢php的狀態(tài)信息
首先,在php的配置文件中添加一行
vim /usr/local/php/etc/php-fpm.conf
pm.status_path = /phpfpmstatus
保存后重啟php-fpm
在nginx配置文件中添加代碼
server
{
listen localhost:80;
server_name localhost;
location /nginxstatus {
stub_status on;
access_log off;
allow 127.0.0.1;
allow 10.6.0.187;
deny all;
}
location ~ ^/(phpfpmstatus)$ {
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
保存后重啟nginx
然后使用curl -s http://localhost/phpfpmstatus查看是否能夠獲取到php狀態(tài)信息
然后,在zabbix的腳本目錄里面編輯執(zhí)行腳本
#!/bin/bash
#monitor php-fpm status from zabbix
#lincense:GPL
#mail:admin@huxianglin.cn
#date:2015.04.15
source /etc/bashrc >/dev/null 2>&1
source /etc/profile >/dev/null 2>&1
LOG=/usr/local/zabbix-2.4.4/scripts/phpfpmstatus.log
curl -s http://localhost/phpfpmstatus >$LOG
pool(){
awk '/pool/ {print $NF}' $LOG
}
process_manager(){
awk '/process manager/ {print $NF}' $LOG
}
start_since(){
awk '/start since:/ {print $NF}' $LOG
}
accepted_conn(){
awk '/accepted conn:/ {print $NF}' $LOG
}
listen_queue(){
awk '/^(listen queue:)/ {print $NF}' $LOG
}
max_listen_queue(){
awk '/max listen queue:/ {print $NF}' $LOG
}
listen_queue_len(){
awk '/listen queue len:/ {print $NF}' $LOG
}
idle_processes(){
awk '/idle processes:/ {print $NF}' $LOG
}
active_processes(){
awk '/^(active processes:)/ {print $NF}' $LOG
}
total_processes(){
awk '/total processes:/ {print $NF}' $LOG
}
max_active_processes(){
awk '/max active processes:/ {print $NF}' $LOG
}
max_children_reached(){
awk '/max children reached:/ {print $NF}' $LOG
}
case "$1" in
pool)
pool
;;
process_manager)
process_manager
;;
start_since)
start_since
;;
accepted_conn)
accepted_conn
;;
listen_queue)
listen_queue
;;
max_listen_queue)
max_listen_queue
;;
listen_queue_len)
listen_queue_len
;;
idle_processes)
idle_processes
;;
active_processes)
active_processes
;;
total_processes)
total_processes
;;
max_active_processes)
max_active_processes
;;
max_children_reached)
max_children_reached
;;
*)
echo "Usage: $0 {pool|process_manager|start_since|accepted_conn|listen_queue|max_listen_queue|listen_queue_len|idle_processes|active_processes|total_processes|max_active_processes|max_children_reached}"
esac
保存后退出,修改權(quán)限為
-rwxr-xr-x 1 zabbix zabbix 1770 4月 15 14:50 phpstatus.sh
然后編輯zabbix_agentd.conf文件,在最后添加上下面這段代碼,并重啟zabbix_agentd服務(wù)
#to monitor php-fpmstatus
UserParameter=phpfpm.status.pool,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh pool
UserParameter=phpfpm.status.process.manager,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh process_manager
UserParameter=phpfpm.status.start.since,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh start_since
UserParameter=phpfpm.status.accepted.conn,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh accepted_conn
UserParameter=phpfpm.status.listen.queue,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh listen_queue
UserParameter=phpfpm.status.max.listen.queue,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh max_listen_queue
UserParameter=phpfpm.status.listen.queue.len,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh listen_queue_len
UserParameter=phpfpm.status.idle.processes,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh idle_processes
UserParameter=phpfpm.status.active.processes,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh active_processes
UserParameter=phpfpm.status.total.processes,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh total_processes
UserParameter=phpfpm.status.max.active.processes,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh max_active_processes
UserParameter=phpfpm.status.max.children.reached,/usr/local/zabbix-2.4.4/scripts/phpstatus.sh max_children_reached
然后就可以在web端配置item監(jiān)控php狀態(tài)了
網(wǎng)頁題目:zabbix監(jiān)控php狀態(tài)
當(dāng)前路徑:http://m.newbst.com/article10/ijsido.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站導(dǎo)航、Google、全網(wǎng)營銷推廣、響應(yīng)式網(wǎng)站、域名注冊、移動網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)