Zabbix monitoring Php-status and process resource usage

Source: Internet
Author: User
Tags configuration php fpm

After the entry, the leader let me start Zabbix monitoring deployment and specific maintenance. Monitoring PHP First is a very important thing. Zabbix monitoring php can be monitored by PHP with a status function, need to open in the configuration file, while the Nginx configuration PHP status can be accessed

1.PHP-FPM Open Status

grep Pm.status_path/usr/local/php/etc/php-fpm.confpm.status_path =/php-fpm-status

The default is/status, of course, can also be changed to/phpfpm_status, I am here to change to/php-fpm-status

2.nginx Configuration

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.P HP Status Detailed

POOL–FPM pool name, mostly wwwprocess manager– process management mode, value: Static, dynamic or OnDemand. Dynamicstart time– Start date, if Reload php-fpm, the time will update the start since– run time accepted conn– the number of requests received by the current pool listen queue– request waiting queue, if this value is not 0, Then to increase the number of FPM processes Max Listen queue– request wait queue highest number listen queue Len–socket wait Queue Length idle processes– idle Process number Active processes– active process number Total processes– Overall process quantity Max active processes– max active process number (FPM start count) Max children reached-the number of times the maximum limit of the avenue process is limited, if this number is not 0, that indicates your maximum process The quantity is too small, please change it a little larger. Slow requests– enabled PHP-FPM Slow-log, number of slow requests

4. Add Zabbix_agent Configuration

[email protected] zabbix_agentd.conf.d]# cat check_php_status.conf userparameter=php-fpm.status[*],/etc/zabbix/ alertscripts/php_status.sh $1userparameter=php_status,ps-ef | grep php-fpm |  awk ' {print $9} ' | grep Master | Wc-luserparameter=process.php.memory,/home/hckjs213/zabbix/etc/script/processstatus.sh phpmemUserParameter= Process.php.cpu,/home/hckjs213/zabbix/etc/script/processstatus.sh phpcpuuserparameter=process.php.num,/home/ Hckjs213/zabbix/etc/script/processstatus.sh Phpnum


5. Write a PHP monitoring script

#!/bin/bashcurl= ' 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  == " " ];thenecho 0elseecho   $outputfi          }$1

PHP Process Resource Usage Script

#!/bin/bash#chck for PHP and Sphinx used CPU and Memoryphpmem () {PS aux|grep "php" |grep-v "grep" |grep-v "Processstatu s.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 "$" inphpmem) Phpmem; ;p hpcpu) phpcpu;; Phpnum) Phpnum;; *) echo "Usage: $ phpmem|phpcpu|phpnum}" Esac

6. Testing

[Email protected]_server ~]#/usr/local/zabbix/bin/zabbix_get-s 192.168.50.119-k php-fpm.status[active] 1[[email Protected]_server ~]# zabbix_get-s 10.144.164.53-p 10050-k process.php.memory 2070688

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/8B/97/wKiom1hSD6ezT2G_AACPEZHIDFc105.png "title=" Eae22684-b027-483f-a42e-a545faddf594.png "alt=" Wkiom1hsd6ezt2g_aacpezhidfc105.png "/>

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/8B/93/wKioL1hSD9qBT6MbAACPW9hXpLE213.png "title=" QQ picture 20161215113650.png "alt=" Wkiol1hsd9qbt6mbaacpw9hxple213.png "/>

This article from "Do not abandon!" Do not give up "blog, be sure to keep this source http://thedream.blog.51cto.com/6427769/1882958

Zabbix monitoring Php-status and process resource usage

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.