入職以后,領(lǐng)導(dǎo)讓我著手zabbix監(jiān)控的部署和具體的維護(hù)。監(jiān)控php首先就是一個(gè)挺重要的事情了。zabbix監(jiān)控php可以通過(guò)php自帶的一個(gè)status功能來(lái)監(jiān)控,需要在配置文件里面開(kāi)啟,同時(shí)在nginx里面配置php status可以訪問(wèn)
在成都做網(wǎng)站、網(wǎng)站設(shè)計(jì)中從網(wǎng)站色彩、結(jié)構(gòu)布局、欄目設(shè)置、關(guān)鍵詞群組等細(xì)微處著手,突出企業(yè)的產(chǎn)品/服務(wù)/品牌,幫助企業(yè)鎖定精準(zhǔn)用戶,提高在線咨詢和轉(zhuǎn)化,使成都網(wǎng)站營(yíng)銷(xiāo)成為有效果、有回報(bào)的無(wú)錫營(yíng)銷(xiāo)推廣。成都創(chuàng)新互聯(lián)專業(yè)成都網(wǎng)站建設(shè)10多年了,客戶滿意度97.8%,歡迎成都創(chuàng)新互聯(lián)客戶聯(lián)系。
1.php-fpm 開(kāi)啟status
grep pm.status_path /usr/local/php/etc/php-fpm.conf pm.status_path = /php-fpm-status
默認(rèn)情況下為/status,當(dāng)然也可以改成/phpfpm_status等,我這里是改成/php-fpm-status
2.nginx配置
server { listen 80; server_name 127.0.0.1; location /phpfpm_status { fastcgi_pass 127.0.0.1:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; } }
3.php status詳解
pool – fpm池子名稱,大多數(shù)為www process manager – 進(jìn)程管理方式,值:static, dynamic or ondemand. dynamic start time – 啟動(dòng)日期,如果reload了php-fpm,時(shí)間會(huì)更新 start since – 運(yùn)行時(shí)長(zhǎng) accepted conn – 當(dāng)前池子接受的請(qǐng)求數(shù) listen queue – 請(qǐng)求等待隊(duì)列,如果這個(gè)值不為0,那么要增加FPM的進(jìn)程數(shù)量 max listen queue – 請(qǐng)求等待隊(duì)列最高的數(shù)量 listen queue len – socket等待隊(duì)列長(zhǎng)度 idle processes – 空閑進(jìn)程數(shù)量 active processes – 活躍進(jìn)程數(shù)量 total processes – 總進(jìn)程數(shù)量 max active processes – 最大的活躍進(jìn)程數(shù)量(FPM啟動(dòng)開(kāi)始算) max children reached - 大道進(jìn)程最大數(shù)量限制的次數(shù),如果這個(gè)數(shù)量不為0,那說(shuō)明你的最大進(jìn)程數(shù)量太小了,請(qǐng)改大一點(diǎn)。 slow requests – 啟用了php-fpm slow-log,緩慢請(qǐng)求的數(shù)量
4.添加zabbix_agent 配置
[root@localhost zabbix_agentd.conf.d]# cat check_php_status.conf UserParameter=php-fpm.status[*],/etc/zabbix/alertscripts/php_status.sh $1 UserParameter=php_status,ps -ef | grep php-fpm | awk '{ print $9}' | grep master | wc -l UserParameter=process.php.memory,/home/hckjS213/zabbix/etc/script/processstatus.sh phpmem UserParameter=process.php.cpu,/home/hckjS213/zabbix/etc/script/processstatus.sh phpcpu UserParameter=process.php.num,/home/hckjS213/zabbix/etc/script/processstatus.sh phpnum
5.編寫(xiě)php監(jiān)控腳本
#!/bin/bash CURL=`which curl` function idle { $CURL "http://127.0.0.1/php-fpm-status" 2>/dev/null| grep -w '^idle processes:' | awk '{print $3}' } function total { $CURL "http://127.0.0.1/php-fpm-status" 2>/dev/null| grep -w '^total processes:' | awk '{print $3}' } function active { $CURL "http://127.0.0.1/php-fpm-status" 2>/dev/null| grep -w '^active processes:' | awk '{print $3}' } function listen_queue { $CURL "http://127.0.0.1/php-fpm-status" 2>/dev/null| grep -w "^listen queue:" | awk '{print $3}' } function slow_requests { output=` $CURL "http://127.0.0.1/php-fpm-status" 2>/dev/null| grep -w "^slow requests:"| awk '{print $3}'` if [ "$output" == "" ];then echo 0 else echo $output fi } $1
php進(jìn)程資源使用率腳本
#!/bin/bash #chck for php and sphinx used cpu and memory phpmem(){ ps aux|grep "php"|grep -v "grep"|grep -v "processstatus.sh"|awk '{sum+=$6}; END{print sum}' } phpcpu(){ ps aux|grep "php"|grep -v "grep"|grep -v "processstatus.sh"|awk '{sum+=$3}; END{print sum}' } phpnum(){ ps aux|grep "php"|grep -v "grep"|grep -v "processstatus.sh"| wc -l } case "$1" in phpmem) phpmem ;; phpcpu) phpcpu ;; phpnum) phpnum ;; *) echo "Usage: $0 {phpmem|phpcpu|phpnum}" esac
6.測(cè)試
[root@Zabbix_server ~]#/usr/local/zabbix/bin/zabbix_get -s 192.168.50.119 -k php-fpm.status[active] 1 [root@Zabbix_server ~]# zabbix_get -s 10.144.164.53 -p 10050 -k process.php.memory 2070688
新聞標(biāo)題:zabbix監(jiān)控php-status和進(jìn)程資源使用率
鏈接地址:http://jinyejixie.com/article44/ggihee.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、面包屑導(dǎo)航、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站排名、軟件開(kāi)發(fā)、網(wǎng)站改版
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)