A few days ago, I got an nginx service monitor, and today we try to monitor the PHP service.
Operating system: CentOS 7.2
PHP Version: 5.6.30
Zabbix version: 2.2.5
Discover that PHP-FPM and Nginx have their own status page to provide a view, so we can open it in the config file
First check to see if your PHP profile turns on the Status Page view feature
# Cat/data0/php/etc/php-fpm.conf | grep status_path;p M.status_path =/status
If that's the case, it's not turned on yet, so let's modify the configuration so that it supports viewing the PHP-FPM status
# vim/data0/php/etc/php-fpm.conf Pm.status_path =/status---removed;
Save exit
Restart the PHP-FPM service and let the View status function take effect
# pkill-9 php-fpm#/data0/php/sbin/php-fpm
Add support for PHP status on nginx configuration
# vim /data0/nginx/conf/nginx.conf# #在server模块内添加即可server { listen 80; server_name www.sss.com; #20170701 php-fpm status for zabbix to fetch data location ~ ^/(status|ping) $ { include fastcgi_params; fastcgi_pass 172.17.0.2:9000; fastcgi_param SCRIPT_FILENAME $document _root$fastcgi_script_name; } #20170701 php-fpm status for zabbix to fetch data end}
Note: Because my PHP is running inside Docker, the above fatstcgi_pass depends on your own situation.
Setup complete, save exit, restart Nginx service, let the setting take effect
#/data0/nginx/sbin/nginx-tnginx:the Configuration file/data0/nginx/conf/nginx.conf syntax is oknginx:configuration f ile/data0/nginx/conf/nginx.conf test is successful#/data0/nginx/sbin/nginx-s reload
At this point, PHP, nginx ready to work, you can now start to see the results
View your Status page
There are two ways of doing this:
1. On-Premises access
Curl/HTTP/url/status
# curl http://www.sss.com/statuspool: wwwprocess manager: Dynamicstart time: 30/jun/2017:14:14:02 +0800start since: 94540accepted conn: 75834listen queue: 0max listen queue: 2listen queue len: 128idle processes: 99active processes: 1total processes: 100max active processes: 9max children reached: 0slow requests: 122
2. Open Browser access
http +/URL/status
650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M00/9A/CC/wKioL1la7OahgXjQAAAjtPcLJ64868.png "title=" Status. PNG "alt=" Wkiol1la7oahgxjqaaajtpclj64868.png "/>
Content Explanation:
POOL:         WWW --PHP-FPM Pool name process manager: dynamic --Process Management Mode start time: 30/jun/ 2017:14:14:02 +0800 --start date, once you update the PHP-FPM service, it will also be updated start since: 94540 --run to the current time accepted conn: 75834 --the number of requests accepted by the pool listen queue: 0 --the number of requests waiting queues, if this value is greater than 0, increase the number of PHP-FPM processes Max listen queue: 2 --maximum number of requests waiting queues Listen queue len: 128 --socket waiting Queue Length idle processes: 99 --number of idle processes active processes: 1 -- Number of active processes total processes: 100 --Total number of processes max active processes: 9 --Maximum number of active processes max children reached: 0 --Avenue maximum number of limit times, also if this value is not 0, the maximum process needs to be expanded to meet the demand slow Requests: 122 --Slow Request Count
PHP-FPM Status page very friendly place is in conjunction with Zabbix monitoring, do not need you to write shell script to get data, good, and can be lazy!
Do not believe, on your monitored host (that is, the PHP-FPM host) to try the following practices
1. Access the URL at the end of the add? Xml
Curl Http://www.sss.com/status?xml<?xml version= "1.0"?><status><pool>www</pool>< process-manager>dynamic</process-manager><start-time>1498803242</start-time>< Start-since>95730</start-since><accepted-conn>77180</accepted-conn><listen-queue>0 </listen-queue><max-listen-queue>2</max-listen-queue><listen-queue-len>128</ listen-queue-len><idle-processes>99</idle-processes><active-processes>1</ active-processes><total-processes>100</total-processes><max-active-processes>9</ max-active-processes><max-children-reached>0</max-children-reached><slow-requests>122< /slow-requests>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9A/CC/wKiom1la7YnjxJigAABKVw_KNfc578.png "title=" XML. PNG "alt=" Wkiom1la7ynjxjigaabkvw_knfc578.png "/>
2. Access URL at the end of the add? HTML
curl http:/www.sss.com/devopsfjjerpstatus?html<! doctype html public "-//w3c//dtd xhtml 1.0 strict//en" "http://www.w3.org/ Tr/xhtml1/dtd/xhtml1-strict.dtd ">650) this.width=650; "src=" Https://s1.51cto.com/wyfs02/M02/9A/CC/wKioL1la7a3gvfyrAAAzeo2PQWM462.png "title=" HTML. PNG "alt=" Wkiol1la7a3gvfyraaazeo2pqwm462.png "/>
3. Access the URL at the end of the add? Json
# Curl http://www.sss.com/status?json{"pool": "www", "Process Manager": "Dynamic", "Start Time": 1498803242, "start since ": 96133," accepted conn ": 77639," Listen queue ": 0," Max Listen queue ": 2," Listen Queue Len ": $," Idle Processes ": 99," Active Processes ": 1," Total processes ": +," Max Active Processes ": 9," Max Children reached ": 0," slow requests ": 122}
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/9A/CC/wKioL1la7fSwXJnNAAAfXT-YvxU968.png "title=" json. PNG "alt=" Wkiol1la7fswxjnnaaafxt-yvxu968.png "/>
Add a custom parameter to the configuration of the Zabbix agent of the monitored machine
vim/data0/zabbix/etc/zabbix_agentd.conf# #monitoring for PHP-FPM statususerparameter=php-fpm.status[*],/usr/bin/ Curl-s "Http://www.sss.com/devopsfjjerpstatus?xml" | grep "<$1>" | Awk-f ' >|< ' {print $$3} '
In order for the modified configuration to take effect, we will restart the next Zabbix_agentd service
# pkill-9 zabbix_agentd#/data0/zabbix/sbin/zabbix_agentd
Currently the settings on the monitored machine have basically ended, now moved to Zabbix server, as in the previous operation, as long as the Zabbix Web management interface to import PHP-FPM monitoring templates
Note: If you need a friend, you can download my Zabbix php-fpm monitoring template at the end of this article
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9A/CC/wKioL1la7zXSnLmqAABBJK1MKJU635.png "title=" before sinks. PNG "alt=" Wkiol1la7zxsnlmqaabbjk1mkju635.png "/>
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/9A/CC/wKioL1la7zbQgONsAACVE2acj7E116.png "title=" will be selected. PNG "alt=" Wkiol1la7zbqgonsaacve2acj7e116.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9A/CC/wKiom1la7zfwy_r3AACVQTxn2_Q223.png "title=" SELECT XML . PNG "alt=" Wkiom1la7zfwy_r3aacvqtxn2_q223.png "/>
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/9A/CC/wKiom1la76nzuDgwAACZzXCM5mo993.png "title=" was successfully remitted. PNG "alt=" Wkiom1la76nzudgwaaczzxcm5mo993.png "/>
When the above import succeeds, look in your template list to see if the import has already been entered
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9A/CC/wKioL1la7-7z_ExEAAAOGOYC4Xo350.png "title=" module to find. PNG "alt=" Wkiol1la7-7z_exeaaaogoyc4xo350.png "/>
As you can see from the above figure, there is a template called the Templates App php-fpm.
View Monitoring Project Content
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9A/D1/wKioL1lbC-ujxVleAAET-TUuEyg658.png "title=" project. PNG "alt=" Wkiol1lbc-ujxvleaaet-tuueyg658.png "/>
View monitoring triggers
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9A/D1/wKiom1lbDA6hzobPAAB51BgiDno471.png "title=" alarm. PNG "alt=" Wkiom1lbda6hzobpaab51bgidno471.png "/>
View Monitoring Graphics content
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9A/D1/wKioL1lbDDihu-PrAACDfuMe3rE453.png "title=" graphic. PNG "alt=" Wkiol1lbddihu-praacdfume3re453.png "/>
Next, link this template to the host you need to monitor the PHP-FPM service, the simplest way is to include the host in the monitoring template
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9A/CF/wKioL1la_p6xv87LAAC5-9cP0nc367.png "title=" The host is included in the template. PNG "alt=" Wkiol1la_p6xv87laac5-9cp0nc367.png "/>
can go to your host to see if it has been connected to your host
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9A/D1/wKiom1lbC3OR5i7PAAClrvJuMLU538.png "title=" connection template. PNG "alt=" Wkiom1lbc3or5i7paaclrvjumlu538.png "/>
found that the template App php_fpm is already in the link templates of the host
If the template is not appropriate, you can set up a monitoring template, the Zabbix monitoring version may be different, but basically the same, according to their own needs to set.
First create a monitoring template
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9A/CD/wKioL1la9Bzy7ogDAAA_8qBOJ8I032.png "title=" before the creation of a mold. PNG "alt=" Wkiol1la9bzy7ogdaaa_8qboj8i032.png "/>
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M00/9A/CD/wKioL1la9DiTvl9jAACtGiDFSlw824.png "title=" Create a template. png "alt=" Wkiol1la9ditvl9jaactgidfslw824.png "/>
Select the group template, then fill in the desired template name and the host to be included in the monitoring template
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9A/CE/wKiom1la_dWSdUwKAABNq_6RvQk772.png "title=" template content. PNG "alt=" Wkiom1la_dwsduwkaabnq_6rvqk772.png "/>
2. After configuring the template, create an app set
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9A/CD/wKioL1la9quiz7LuAAA-YrewPVY443.png "title=" before you create an app . PNG "alt=" Wkiol1la9quiz7luaaa-yrewpvy443.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9A/CD/wKioL1la9l6iKBa2AAAYOfCmg6M539.png "title=" Create an app set . PNG "alt=" Wkiol1la9l6ikba2aaayofcmg6m539.png "/>
3. Adding monitoring items to the app set
Note: For the monitoring project, I can refer to the monitoring item name and the key value that I posted on the Monitoring project content.
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9A/CD/wKiom1la9uyRwgeRAAA-hMDd778111.png "title=" Create a monitor item icon. PNG "alt=" Wkiom1la9uyrwgeraaa-hmdd778111.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M02/9A/CD/wKioL1la9uzQkjW0AAB-hhJou2w747.png "title=" creates the project. PNG "alt=" Wkiol1la9uzqkjw0aab-hhjou2w747.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9A/CE/wKioL1la-5rjwpccAABhfBv-9f8647.png "title=" Create a project backend. PNG "alt=" Wkiol1la-5rjwpccaabhfbv-9f8647.png "/>
Other monitoring items and the above content, in addition to the name, key values, notes description information, the others are the same.
4. Adding monitoring alarms
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9A/CE/wKioL1la96iQSUMwAABGcua_keM434.png "title=" Create a trigger picture. PNG "alt=" Wkiol1la96iqsumwaabgcua_kem434.png "/>
650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M00/9A/CD/wKiom1la96mTUlWPAABey5oyC9U998.png "title=" creates a warning. PNG "alt=" Wkiom1la96mtulwpaabey5oyc9u998.png "/>
The above alarm is a critical alarm when the PHP-FPM process is zero.
5. Add a monitoring item to view the graph
Note: For the monitoring of graphics can refer to I posted in the monitoring graphic content of the monitoring graphics name as a reference, mainly according to your own needs to set up will be more accurate
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9A/CE/wKioL1la-p-wsvQHAAA97XT7C98179.png "title=" create icon. PNG "alt=" Wkiol1la-p-wsvqhaaa97xt7c98179.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M02/9A/CE/wKiom1la-qDAscrdAACPUvoUAOg476.png "title=" Graphics create content. PNG "alt=" Wkiom1la-qdascrdaacpuvouaog476.png "/>
Fill in the name of the monitor name you want, in the monitoring item select you have added a good project, anyway, according to your personal needs to set up
Set up the above things, then you can directly in the monitoring of your monitoring graph to see if there is data generated
650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M02/9A/D5/wKioL1lbK4eSr2raAAD_uMDz1r0217.png "title=" 1.PNG "alt=" Wkiol1lbk4esr2raaad_umdz1r0217.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9A/D5/wKioL1lbKyPiCPiiAAD67wwLqpM027.png "style=" float : none; "title=" 2.PNG "alt=" Wkiol1lbkypicpiiaad67wwlqpm027.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M01/9A/D4/wKiom1lbKySwHm-gAAD3ICk44vI168.png "style=" float : none; "title=" 3.PNG "alt=" Wkiom1lbkyswhm-gaad3ick44vi168.png "/>
At this point all creation actions end, if the plot, then the setting is successful!
This article is from the "10793382" blog, please be sure to keep this source http://10803382.blog.51cto.com/10793382/1944397
PHP-FPM services included in Zabbix monitoring