溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

zabbix監(jiān)控php狀態(tài)(四)

發(fā)布時間:2020-07-20 02:42:41 來源:網(wǎng)絡(luò) 閱讀:765 作者:ckl893 欄目:web開發(fā)

1.nginx配置增加狀態(tài)

vim /app/local/nginx/conf/vhosts/php-fpm_status.conf 
server {
    listen  *:81 default_server;
    server_name _;
    location /php-fpm-status {
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    include fastcgi_params;
    fastcgi_pass 127.0.0.1:9000;
    }
}


2.測試訪問

# curl http://localhost:81/php-fpm-status
pool:                 www
process manager:      static
start time:           09/Jan/2017:16:09:17 +0800
start since:          176354
accepted conn:        5538266
listen queue:         0
max listen queue:     31
listen queue len:     65535
idle processes:       298
active processes:     2
total processes:      300
max active processes: 300
max children reached: 0
slow requests:        1102

3.增加監(jiān)控腳本

vim php_stat.sh 
#!/bin/bash
source /etc/bashrc >/dev/null 2>&1
source /etc/profile >/dev/null 2>&1

LOG=/usr/local/zabbix-agent/logs/phpfpmstatus.log
curl -s http://127.0.0.1:81/php-fpm-status >$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

4.增加配置參數(shù)

vim /app/local/nginx/conf/vhosts/php-fpm_status.conf 
#phpstatus
UserParameter=phpfpm.status.pool,/usr/local/zabbix-agent/scripts/php_stat.sh pool
UserParameter=phpfpm.status.process.manager,/usr/local/zabbix-agent/scripts/php_stat.sh process_manager
UserParameter=phpfpm.status.start.since,/usr/local/zabbix-agent/scripts/php_stat.sh start_since
UserParameter=phpfpm.status.accepted.conn,/usr/local/zabbix-agent/scripts/php_stat.sh accepted_conn
UserParameter=phpfpm.status.listen.queue,/usr/local/zabbix-agent/scripts/php_stat.sh listen_queue
UserParameter=phpfpm.status.max.listen.queue,/usr/local/zabbix-agent/scripts/php_stat.sh max_listen_queue
UserParameter=phpfpm.status.listen.queue.len,/usr/local/zabbix-agent/scripts/php_stat.sh listen_queue_len
UserParameter=phpfpm.status.idle.processes,/usr/local/zabbix-agent/scripts/php_stat.sh idle_processes
UserParameter=phpfpm.status.active.processes,/usr/local/zabbix-agent/scripts/php_stat.sh active_processes
UserParameter=phpfpm.status.total.processes,/usr/local/zabbix-agent/scripts/php_stat.sh total_processes
UserParameter=phpfpm.status.max.active.processes,/usr/local/zabbix-agent/scripts/php_stat.sh max_active_processes
UserParameter=phpfpm.status.max.children.reached,/usr/local/zabbix-agent/scripts/php_stat.sh max_children_reached

5.重啟進程

/etc/init.d/zabbix_agentd restart

6.增加模板

zabbix監(jiān)控php狀態(tài)(四)

7.增加item

zabbix監(jiān)控php狀態(tài)(四)

8.增加監(jiān)控圖像

zabbix監(jiān)控php狀態(tài)(四)9.查看監(jiān)控

zabbix監(jiān)控php狀態(tài)(四)

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI