PHP-FPM Integration | Xitoring Document

PHP-FPM Integration

With Xitoring's PHP-FPM integration, users can easily access real-time performance metrics such as memory usage, request duration, and CPU utilization, allowing them to quickly identify and troubleshoot any performance issues that may arise. Additionally, Xitoring provides advanced alerting capabilities that can notify users of any potential problems, empowering them to take proactive steps to prevent downtime and ensure optimal application performance.

By leveraging Xitoring's monitoring capabilities for PHP-FPM, users can gain greater visibility into their PHP-based applications, enhancing their ability to deliver a seamless and reliable user experience.

Enable PHP-FPM Integration

Supported platforms

The following guide is working on Linux and Windows servers but some details could be quite different based on the OS version.

To enable PHP-FPM Integration on Xitoring, first, you need to make some changes in PHP-FPM configurations so it publishes statistics for Xitogent.

On Linux

Open the PHP-FPM configuration file with a text editor. (the following path is the location for the PHP-FPM configuration file on Ubuntu the location of the PHP-FPM configuration file could be quite different on different distros).

vim /etc/php/php-fpm.d/www.conf
1

Uncomment the following lines in the config file:

pm.status_path = /fpm/status
ping.path = /fpm/ping
1
2

After that just restart your PHP-FPM service using the systemctl command:

systemctl restart php-fpm
1

On Windows Server

Open the PHP-FPM configuration file with a text editor. The location of the configuration file may differ depending on the installation and setup of PHP-FPM on your system. The default location for PHP-FPM on Windows with PHP 7.4 and later is C:\Program Files\PHP\v7.X\php-fpm.d\www.conf.

notepad "C:\Program Files\PHP\v7.X\php-fpm.d\www.conf"
1

Uncomment the following lines in the configuration file by removing the semicolon; at the beginning of each line:

pm.status_path = /fpm/status
ping.path = /fpm/ping
1
2

These lines enable the status and ping pages for PHP-FPM. Save the changes to the configuration file.

Restart the PHP-FPM service using the net stop and net start commands:

net stop php-fpm
net start php-fpm
1
2

Alternatively, you can use the Restart-Service command in PowerShell:

Restart-Service -Name php-fpm
1

Configure Nginx to serve the statistics

Add the following configurations to your Nginx server block to serve the statistics on the localhost so Xitogent can access the information and it will be secure and not available publicly on the internet:

location ~ ^/fpm/(status|ping)$ {
  allow 127.0.0.1;
  deny  all;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_index index.php;
  include fastcgi_params;
  fastcgi_pass   unix:/var/run/php-fpm/www.sock;
}
1
2
3
4
5
6
7
8

Configure Apache to server statistics

If you are using an Apache web server you can add something like the following config lines:

<VirtualHost *:80>
    ServerName example.com
    DocumentRoot /var/www/html

    <Location /status>
        ProxyPass unix:/var/run/php-fpm.sock|fcgi://localhost/status
        ProxyPassReverse unix:/var/run/php-fpm.sock|fcgi://localhost/status
        ProxyRequests Off
        AllowOverride None
        Require local
    </Location>
</VirtualHost>
1
2
3
4
5
6
7
8
9
10
11
12

TIP

Be sure to replace the essential variables in the configuration with values appropriate for your server, such as the path of the PHP-FPM socket. The examples above are intended to provide a general overview of how the configurations should be set up.

As the final step you just need to call Xitogent CLI with the following command on the server, you want to enable the PHP-FPM integration on:

xitogent integrate
1

Select PHP-FPM from the list of available integrations, it will prompt for the URL of the location that statistics are serving for example:

http://127.0.0.1/fpm/status
1

Create Triggers for PHP-FPM integration

You can create Triggers for PHP-FPM integration and define incidents for the following parameters:

Active Processes
Idle Processes
Request CPU
Request Memory
Listen Queue
1
2
3
4
5
Last Updated: 4/3/2023, 8:51:52 PM