There are no strangers to cacti O & M personnel. it may be the most widely used monitoring tool. Internet-related companies may use cacti to monitor the server running status and the load of some software. Currently, the most common backend technology for websites is php, regardless of nginx or ligh...
There are no strangers to cacti O & M personnel. it may be the most widely used monitoring tool. Internet-related companies may use cacti to monitor the server running status and the load of some software.
Currently, php is the most widely used backend technology for websites. no matter nginx or lighttpd, the load capacity is very strong today. with the efforts of many cool people, tens of thousands to 100,000 concurrent loads are not uncommon. However, it is completely static, and adding php will greatly reduce the efficiency. In fact, the load capacity bottleneck of a dynamic website is usually above php.
Many articles on the Internet show you how cacti monitors the number of nginx concurrent jobs. However, I haven't published any articles about how to monitor the working status of php. I searched google baidu, I didn't find an introduction to monitoring php in Chinese, so I was not idle. I simply transformed a template to monitor the working conditions of php-fpm. I believe many people in China may have used it for a long time, but they have no time to say it.
The so-called transformation is not my original. Original author address in
Http://forums.cacti.net/viewtopic.php? F = 12 & amp; t = 41580
After downloading this template, I tried it and found that it was not so easy to use. I needed support from FCGI: Client and LWP: UserAgent modules in perl, this is a headache for people who are not familiar with perl and cpan. This script in perl has security risks because it uses FCGI: Client. the pm module directly accesses the port 9000 of the php-fpm, which requires your php-fpm to be monitored on another IP address except 127.0.0.1. in this way, if you need cross-data center monitoring, it is necessary to monitor the php-fpm on an Internet IP address unless you specify the php-fpm access IP address or make a VPN. However, I think most companies do not possess this technical strength. Second, if there are more data centers, it is also very troublesome to modify configurations, if you make a mistake, you will be given a 9000 port vulnerability, and someone else will direct an nginx to php to do something bad.
So it took 5 minutes to slightly modify the template and use shell to overwrite the script. Jump php-fpm status monitoring to nginx, get from the web page, both support cross-data center access, without exposing Port 9000 on any IP address, the minimum change to the php-fpm.conf file, the only one is to modify nginx and add a configuration item similar to monitoring nginx. It also requires curl support on the cacti server, but installing curl with yum or apt-get seems much easier than installing the module with cpan. The principle is the same as monitoring nginx with cacti. Therefore, if you have done nginx monitoring, it is very easy to use this template.
However, this script also has a problem, that is, if you use nginx to Mount multiple php-fpm load balancing servers with the upstream backend, data may be inaccurate. In this way, you can access the above connection by directly accessing Port 9000 in the original version.
To use this script, perform the following steps:
1. you need to change the line in the php-fpm.conf file
Find pm. status_path =/status, and remove the comment semicolon. Save and exit
2. open the nginx. conf file
Add the following section to the server {} segment. Be sure not to conflict with the redirection path of your nginx status monitoring. if the redirection path conflicts, modify the settings in php-fpm and nginx at the same time.
Include fastcgi_params;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_param SCRIPT_FILENAME $ fastcgi_script_name;
}
Save and exit
3. restart php-fpm and nginx
Access http: // yourserver/status to check whether php-fpm information can be obtained.
Pool: www
Process manager: dynamic
Start time: 16/Jun/2012: 01: 28: 33 + 0800
Start since: 67269
Accepted conn: 4526202
Listen queue: 0
Max listen queue: 0
Listen queue len: 0
Idle processes: 174
Active processes: 1
Total processes: 175
Max active processes: 23
Max children reached: 0
4. Upload The shell script extracted from the attachment to the cacti/scripts folder of the cacti server. And grant the executable permission. Run the test to check whether the php-fpm status can be obtained.
Cacti_check_php-fpm.sh 114. xxx 80/status
5. import the xml template in the attachment to cacti, and then you will see a php-fpm fastcgi status template when creating a new graph on the device. use it to create the template, and fill in the server IP port and path, you can refer to the test command line to write.
In actual tests, php 5.3.8 and later versions are supported. php versions earlier than 5.3.8 are not tested. if any problem exists, modify the grep part of the script. a total of 15 lines of scripts are supported, easy to understand.
Monitoring results.