Zabbix monitoring PHP

Source: Internet
Author: User
Tags php template

First, open the PHP-FPM status page, this page is similar to Nginx's Stub_status page, recording the PHP running status information

# Cat/etc/php-fpm.d/www.confpm.status_path =/status


Second, configure Nginx Agent to access the status page of PHP

# cat/etc/nginx/conf.d/nginx_status.conf Server {listen-default; server_name _;  Location =/status {Fastcgi_pass 127.0.0.1:9000;fastcgi_indexindex.php;include fastcgi.conf; \ \ This option must be added, no data collected Access_log Off;allow 127.0.0.1;deny all;}


Third, access test to ensure that you can access the page data of the status of PHP

# Curl Http://127.0.0.1/statuspool:wwwprocess manager:dynamicstart TIME:31/3 Month/2016:22:29 : +0800start since:489290accepted conn:3listen Queue:0max listen queue:0listen queue len  : 128idle processes:4active processes:1total Processes:5max Active Processes:1max children reached: 0


Four, write shell script on the agent side, collect the status page information of PHP; The script path is stored in the/opt/zabbix/script/directory

# vim php_fpm_status.sh#!/bin/bashacceptedconn () {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  \\ Add Execute permissions


V. On the agent side, create key, value; location in opt/zabbix/etc/zabbix_agentd.conf.d/directory

# vim php-fpm-nginx.confuserparameter=active.conn, /opt/ Zabbix/script/php_fpm_status.sh acceptedconnuserparameter=listen.queue, /opt/zabbix/script/php_fpm_ status.sh listenqueueuserparameter=max.listen.queue, /opt/zabbix/script/php_fpm_status.sh  maxlistenqueueuserparameter=listen.queue.len,/opt/zabbix/script/php_fpm_status.sh  listenqueuelenuserparameter=idle.processes, /opt/zabbix/script/php_fpm_status.sh  idleprocessesuserparameter=active.processes, /opt/zabbix/script/php_fpm_status.sh  activeprocessesuserparameter=total.processes, /opt/zabbix/script/php_fpm_status.sh  totalprocessesuserparameter=max.active.processes, /opt/zabbix/script/php_fpm_status.sh  maxactiveprocessesuserparameter=max.children.reached, /opt/zabbix/script/php_fpm_status.sh  Maxchildrenreached# /etc/init.d/zabbix_agentd restart  \\ After the above configuration is complete, restart the AGENTD service 


Vi. use Zabbix_get to obtain test data on the server side to see if the configuration was successful

# zabbix_get-s 172.16.100.17-p 10050-k "Active.conn" 42


After seven or more successful operation, create PHP template in Zabbix Web page.

1) Create a template

650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/7E/95/wKiom1cExXOQrU8wAABGXlyS8c4404.png "title=" 1.png " alt= "Wkiom1cexxoqru8waabgxlys8c4404.png"/>


2) Create an app set

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7E/91/wKioL1cExnKxhbVGAABugmPe-UM864.png "title=" 2.png " alt= "Wkiol1cexnkxhbvgaabugmpe-um864.png"/>

3) Create a project

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M01/7E/95/wKiom1cExzmR9mO-AAEwGa4j814510.png "title=" 3.png " alt= "Wkiom1cexzmr9mo-aaewga4j814510.png"/>


4) Create a graphic

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M01/7E/95/wKiom1cEx3jwtbMRAAE-xQ2XkiA126.png "title=" 4.png " alt= "Wkiom1cex3jwtbmraae-xq2xkia126.png"/>

5) Associate this template with the host to view the acquired data

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/7E/92/wKioL1cEzEOD1IMxAAE4aV7Fo_0004.png "title=" 5.png " alt= "Wkiol1cezeod1imxaae4av7fo_0004.png"/>

Here, you can watch the state of PHP at ease while drinking tea.

This article is from the "Trot Empty" blog, be sure to keep this source http://jingfu.blog.51cto.com/6184921/1760965

Zabbix monitoring PHP

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.