PHP-FPM

Note

This plugin is currently being groomed to be an integration. It works, but we haven’t spent a lot of time on it yet to optimize the user experience. Feel free to try it out, just keep in mind that we will be enhancing the experience over time.

PHP-FPM (FastCGI Process Manager) is an alternative PHP FastCGI implementation. This plugin will retrieve phpfpm stats using either HTTP status page or fpm socket.

Setup

The php-fpm plugin is included with the AppOptics host agent by default. Please follow the directions below to enable it for a host agent instance.

Prerequisites

You’ll need to have an Apache server with PHP-FPM accessible. Take note of the host address, port, and password (if set). This will be needed later in the configuration step.

Configuration

The host agent provides an example configuration file to help you get started quickly. It defines the plugin and task file to be loaded by the agent, but requires you to provide the correct settings for your PHP-FPM installation. To enable the plugin:

  1. Make a copy of the PHP-FPM example configuration file /opt/appoptics/etc/plugins.d/phpfpm.yaml.example, renaming it to /opt/appoptics/etc/plugins.d/phpfpm.yaml:
$ sudo cp /opt/appoptics/etc/plugins.d/phpfpm.yaml.example /opt/appoptics/etc/plugins.d/phpfpm.yaml
  1. Edit the configuration file with settings specific to your PHP-FPM install:
$ sudo nano /opt/appoptics/etc/plugins.d/phpfpm.yaml

In this configuration you’ll notice that it is already configured to listen on localhost by using the setting urls: "http://localhost/status". Update this line to specify the server address to listen on.

collector:
  phpfpm:
    all:
      ## An array of addresses to gather stats about. Specify an ip or hostname
      ## with optional port and path
      ##
      ## Plugin can be configured in three modes (either can be used):
      ##   - http: the URL must start with http:// or https://, ie:
      ##       "http://localhost/status"
      ##       "http://192.168.130.1/status?full"
      ##
      ##   - unixsocket: path to fpm socket, ie:
      ##       "/var/run/php5-fpm.sock"
      ##      or using a custom fpm status path:
      ##       "/var/run/php5-fpm.sock:fpm-custom-status-path"
      ##
      ##   - fcgi: the URL must start with fcgi:// or cgi://, and port must be present, ie:
      ##       "fcgi://10.0.0.12:9000/status"
      ##       "cgi://10.0.10.12:9001/status"
      ##
      ## Example of multiple gathering from local socket and remove host
      ## urls: "http://192.168.1.20/status,/tmp/fpm.sock"
      urls: "http://localhost/status"

load:
  plugin: snap-plugin-collector-bridge-phpfpm
  task: task-bridge-phpfpm.yaml

Save your changes and return to the command prompt.

  1. Restart the agent after any configuration changes have been made:
$ sudo service appoptics-snapteld restart
  1. Enable the PHP-FPM plugin

On the Integrations Page you will see PHP-FPM available if the previous steps were successful. It may take a couple minutes before the PHP-FPM plugin is identified.

Select the PHP-FPM plugin to open the configuration menu in the UI, and enable the plugin.

Metrics and Tags

Metrics

The table below outlines the default set of metrics collected by the php-fpm plugin.

Namespace Description
phpfpm.accepted_conn The number of request accepted by the pool
phpfpm.listen_queue The number of request in the queue of pending connections. If this number is non-zero then you should increase the number of process FPM can spawn
phpfpm.max_listen_queue The maximum number of requests in the queue of pending connections since FPM has started
phpfpm.listen_queue_len The size of the socket queue of pending connections
phpfpm.idle_processes The number of idle processes
phpfpm.active_processes The number of active processes
phpfpm.total_processes The number of idle + active processes
phpfpm.max_active_processes The maximum number of active processes since FPM has started
phpfpm.max_children_reached The number of times the process limit has been reached (when pm tries to start more children). If that value is not zero then you may need to increase max process limit for your PHP-FPM pool.
phpfpm.slow_requests The number of slow requests. Enable php-fpm slow-log before you consider this. If this value is non-zero you may have slow php processes. Poorly written mysql queries are generally culprit.

Tags

The table below outlines the default set of tags provided for each metric.

Tags Description
hostname Name of the host. Instead of using this tag we recommend using the @host alias.
server Name of the server
port Port which the server is running on