5.02021-11-21T21:44:27ZTemplates/ApplicationsApp PHP-FPMApp PHP-FPM## Overview
(Check the latest version and updates to this doc at the repo: <https://github.com/vigrai/zabbix-template-php-fpm> )
# Zabbix 4.0 Template for PHP-FPM Pools
This is a template for monitoring php-fpm and it's pools with [Zabbix](www.zabbix.com).
What's special about this template, is that it *automatically* detects (using LLD) the running php-fpm pools and creates items for measuring metrics from each pool. It uses Http Agent type check in zabbix in order to parse the php status information into useful metrics.
So, if you are running a server with multiple php-fpm pools, this may be a better alternative for monitoring php than other templates available.
# Compatibility
This template was tested using:
| Software | Vesion |
| ------ | ------ |
| Zabbix Server | 4.0.3 |
| Debian | Stretch (9.8) |
| Php-fpm | 7.2 |
It might also work with other combination of versions.
# Metrics
This are the metrics created for each php-fpm pool:
![N|Solid](https://github.com/vigrai/zabbix-template-php-fpm/blob/master/img/metrics.png)
# Requirements
- Php-status should be enabled in the php-fpm pools.
- Php-status should be accessible and located in /php-status\_POOLNAME for each pool (see step 4 of Setup).
# Setup
Even though this template is made with automation in mind, there's still some manual steps to be done in the client (where php-fpm and zabbix-agent are running) in order to get it working:
1. Clone this template into a temporary directory.
```
# git clone https://github.com/vigrai/zabbix-template-php-fpm.git /tmp/zabbix-template
```
2. Put the file `php-fpm.discover\_pools.pl` into the /etc/zabbix directory and make it executable.
```
# cp /tmp/zabbix-template/php-fpm.discover\_pools.pl /etc/zabbix
# chmod +x /etc/zabbix/php-fpm.discover\_pools.pl
# chown zabbix.zabbix /etc/zabbix/php-fpm.discover\_pools.pl
```
3. Copy the file userparameter\_php-fpm.conf into /etc/zabbix/zabbix\_agentd.d.
```
# cp /tmp/zabbix-template/userparameter\_php-fpm.conf /etc/zabbix/zabbix\_agentd.d
```
4. Make sure that your php-fpm is correctly setup:
[x] The pools should have php-status enabled.
[x] Php-status should be available in the path /fpm-status\_[NAME-OF-THE-POOL]
Example configuration file for pool called *nms* (/etc/php/7.2/fpm/pool.d/nms.conf):
```[nms]```
`
## Author
Fabio Gallese
Templates/ApplicationsPHP-FPMPHP-FPM Pools Discoveryphp-fpm.discover_pools120sPHP-FPM ({#POOLNAME}): Accepted Connections Per SecondDEPENDENTphp-fpm.accepted_conn[{#POOLNAME}]0The number of incoming requests per second that the pool has accepted; when a connection is accepted it is removed from the listen queue (displayed in real time).PHP-FPMPool {#POOLNAME}JSONPATH$['accepted conn']CHANGE_PER_SECONDphp-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Active ProcessesDEPENDENTphp-fpm.active_processes[{#POOLNAME}]0The number of servers current processing a page - the minimum is 1 (so even on a fully idle server, the result will be not read 0).PHP-FPMPool {#POOLNAME}JSONPATH$['active processes']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Listen QueueDEPENDENTphp-fpm.listen_queue[{#POOLNAME}]0The current number of connections that have been initiated, but not yet accepted. If this value is non-zero it typically means that all the available server processes are currently busy, and there are no processes available to serve the next request. Raising pm.max_children (provided the server can handle it) should help keep this number low. This property follows from the fact that PHP-FPM listens via a socket (TCP or file based), and thus inherits some of the characteristics of sockets.PHP-FPMPool {#POOLNAME}JSONPATH$['listen queue']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Listen Queue LenDEPENDENTphp-fpm.listen_queue_len[{#POOLNAME}]0The upper limit on the number of connections that will be queued. Once this limit is reached, subsequent connections will either be refused, or ignored. This value is set by the php-fpm per pool configuration option 'listen.backlog', which defaults to -1 (unlimited). However, this value is also limited by the system (sysctl) value 'net.core.somaxconn', which defaults to 128 on many Linux systems.PHP-FPMPool {#POOLNAME}JSONPATH$['listen queue len']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Max Active ProcessesDEPENDENTphp-fpm.max_active_processes[{#POOLNAME}]0The highest value that 'active processes' has reached since the php-fpm server started. This value should not exceed pm.max_children.PHP-FPMPool {#POOLNAME}JSONPATH$['max active processes']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Max Children ReachedDEPENDENTphp-fpm.max_children_reached[{#POOLNAME}]0The number of times that pm.max_children has been reached since the php-fpm pool started (only applicable if the process manager is ondemand or dynamic).PHP-FPMPool {#POOLNAME}JSONPATH$['max children reached']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Max Listen QueueDEPENDENTphp-fpm.max_listen_queue[{#POOLNAME}]0The maximum number of requests in the queue of pending connections since this FPM pool has started.PHP-FPMPool {#POOLNAME}JSONPATH$['max listen queue']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Pool NameDEPENDENTphp-fpm.pool[{#POOLNAME}]00TEXTThe name of this pool.PHP-FPMPool {#POOLNAME}JSONPATH$['pool']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Process ManagerDEPENDENTphp-fpm.process_manager[{#POOLNAME}]00TEXTThe method used by the process manager to control the number of child processes (possible values: ondemand, dynamic or static) for this pool.PHP-FPMPool {#POOLNAME}JSONPATH$['process manager']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Slow RequestsDEPENDENTphp-fpm.slow_requests[{#POOLNAME}]0The number of requests that exceeded your request_slowlog_timeout value.PHP-FPMPool {#POOLNAME}JSONPATH$['slow requests']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Start SinceDEPENDENTphp-fpm.start_since[{#POOLNAME}]0sHow long has this pool been running.PHP-FPMPool {#POOLNAME}JSONPATH$['start since']php-fpm.status[{#POOLNAME}]PHP-FPM ({#POOLNAME}): Start TimeDEPENDENTphp-fpm.start_time[{#POOLNAME}]0unixtimeThe time when this pool was started.PHP-FPMPool {#POOLNAME}JSONPATH$['start time']php-fpm.status[{#POOLNAME}]PHP-FPM Pool {#POOLNAME} status pageHTTP_AGENTphp-fpm.status[{#POOLNAME}]60s0TEXTPHP-FPM{$PROTO}://{$HOST.PHPFPM}/fpm-status_{#POOLNAME}?jsonNOPHP-FPM ({#POOLNAME}): Total ProcessesDEPENDENTphp-fpm.total_processes[{#POOLNAME}]0The total number of server processes currently running; the sum of idle processes + active processes. If the process manager is static, this number will match pm.max_children.PHP-FPMPool {#POOLNAME}JSONPATH$['total processes']php-fpm.status[{#POOLNAME}]Memory Used by Pool {#POOLNAME}proc.mem["php-fpm: pool {#POOLNAME}",,,,pmem]120sFLOAT%PHP-FPMPool {#POOLNAME}Process for pool {#POOLNAME}proc.num["php-fpm: pool {#POOLNAME}"]60sPHP-FPMPool {#POOLNAME} processFIXEDBOLD_LINE1A7C11- App PHP-FPMphp-fpm.active_processes[{#POOLNAME}]
1BOLD_LINEF63100- App PHP-FPMphp-fpm.max_active_processes[{#POOLNAME}]
2BOLD_LINE2774A4- App PHP-FPMphp-fpm.total_processes[{#POOLNAME}]
{$HOST.PHPFPM}127.0.0.1:8080{$PROTO}http