PHP-FPM Plugin

The PHP-FPM plugin allows you to monitor the performance of the PHP-FPM process on your server.

Reported Metrics

  • Accepted connections (per second, total)
  • Active processes
  • Total processes
  • Idle processes
  • Max active processes
  • Listen queue
  • Listen queue length
  • Max listen queue
  • Max children reached
  • Start time
  • Start since
  • Pool
  • Process manager
  • Slow requests

Dependencies

  • urllib2
  • json

Enable the PHP-FPM status page

To enable the PHP-FPM status page, add the following code to your PHP-FPM pool configuration file:

pm.status_path = /status_phpfpm 

Now, make the following changes to your configuration file.

NGINX

server
{listen 127.0.0.1:8080;
server_name localhost;
location /status_phpfpm {
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
allow 127.0.0.1;
deny all;
}
}

Apache2

For Apache, edit the /etc/apache2/mods-available/fastcgi.conf file (or similar):

<IfModule mod_fastcgi.c>
# Define a named handler
AddHandler php7-fcgi .php
# Generate an alias pointing to /usr/lib/cgi-bin/php[VersionNumber]-fcgi
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
# Configure an external server handling your upcoming requests (note where the alias is pointing towards)
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization
# only on if fpm-status is match. You might want to put this into your concrete vhost.conf file. For the testing, fastcgi.conf should work.
<LocationMatch "/status_phpfpm">
Order deny,allowD
eny from all
Allow from 127.0.0.1
# set the before defined handler here
SetHandler php7-fcgi
# use the handler for the action handling virtual requests
Action php7-fcgi /php7-fcgi virtual
</LocationMatch>
</IfModule>

You can test if the status page is working by running the following command:

wget -qO- http://127.0.0.1:8080/status_phpfpm?json 

Configure the plugin

To enable the plugin, edit the /etc/agent360-custom.ini file and add the following lines:

[phpfpm]
enabled = yes
status_page_url = http://127.0.0.1:8080/status_phpfpm?json

Test the plugin

Test to see if the plugin is working by running the agent360 --test phpfpm command. It should show the following metrics:

phpfpm:
{
"accepted_conn": 3015,
"accepted_conn_per_second": 0.0,
"active_processes": 1,
"idle_processes": 0,
"listen_queue": 0,
"listen_queue_len": 128,
"max_active_processes": 1,
"max_children_reached": 0,
"max_listen_queue": 1,
"pool": "www",
"process_manager": "ondemand",
"slow_requests": 0,
"start_since": 294686,
"start_time": 1492504250,
"total_processes": 1
}

Now you can restart the agent with the service agent360 restart command.