zabbix_export: version: '5.4' date: '2021-11-21T21:44:29Z' groups: - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6 name: Templates/Applications templates: - uuid: bf289e481ad64e08863dc6c9337aba6c template: 'App PHP-FPM' name: 'App PHP-FPM' description: | ## Overview (Check the latest version and updates to this doc at the repo: ) # 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 groups: - name: Templates/Applications discovery_rules: - uuid: 7ecc4c2f8fb9407d827085db8dd663d2 name: 'PHP-FPM Pools Discovery' key: php-fpm.discover_pools delay: 120s item_prototypes: - uuid: d918946c740c4fb285be7559ca778e92 name: 'PHP-FPM ({#POOLNAME}): Accepted Connections Per Second' type: DEPENDENT key: 'php-fpm.accepted_conn[{#POOLNAME}]' delay: '0' description: 'The 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).' preprocessing: - type: JSONPATH parameters: - '$[''accepted conn'']' - type: CHANGE_PER_SECOND parameters: - '' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 3fdbe0a00fb44f87b7c4294aa1902dee name: 'PHP-FPM ({#POOLNAME}): Active Processes' type: DEPENDENT key: 'php-fpm.active_processes[{#POOLNAME}]' delay: '0' description: 'The 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).' preprocessing: - type: JSONPATH parameters: - '$[''active processes'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: bd1a717d0e3e434d80a04d363e7a4940 name: 'PHP-FPM ({#POOLNAME}): Listen Queue' type: DEPENDENT key: 'php-fpm.listen_queue[{#POOLNAME}]' delay: '0' description: 'The 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.' preprocessing: - type: JSONPATH parameters: - '$[''listen queue'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 96658d6781f74386bdd3bef8d1319cb2 name: 'PHP-FPM ({#POOLNAME}): Listen Queue Len' type: DEPENDENT key: 'php-fpm.listen_queue_len[{#POOLNAME}]' delay: '0' description: 'The 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.' preprocessing: - type: JSONPATH parameters: - '$[''listen queue len'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 00278d53739f49bb861e296ed710faf9 name: 'PHP-FPM ({#POOLNAME}): Max Active Processes' type: DEPENDENT key: 'php-fpm.max_active_processes[{#POOLNAME}]' delay: '0' description: 'The highest value that ''active processes'' has reached since the php-fpm server started. This value should not exceed pm.max_children.' preprocessing: - type: JSONPATH parameters: - '$[''max active processes'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 42818e5f15bf4a7fb03a487f658fb3f8 name: 'PHP-FPM ({#POOLNAME}): Max Children Reached' type: DEPENDENT key: 'php-fpm.max_children_reached[{#POOLNAME}]' delay: '0' description: 'The 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).' preprocessing: - type: JSONPATH parameters: - '$[''max children reached'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: ae252e1806b24a7096fda64b4f4893dc name: 'PHP-FPM ({#POOLNAME}): Max Listen Queue' type: DEPENDENT key: 'php-fpm.max_listen_queue[{#POOLNAME}]' delay: '0' description: 'The maximum number of requests in the queue of pending connections since this FPM pool has started.' preprocessing: - type: JSONPATH parameters: - '$[''max listen queue'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: fcac379e555b4cce87ad86139629e36f name: 'PHP-FPM ({#POOLNAME}): Pool Name' type: DEPENDENT key: 'php-fpm.pool[{#POOLNAME}]' delay: '0' trends: '0' value_type: TEXT description: 'The name of this pool.' preprocessing: - type: JSONPATH parameters: - '$[''pool'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: ad348c0646474b21875e082c2ad16675 name: 'PHP-FPM ({#POOLNAME}): Process Manager' type: DEPENDENT key: 'php-fpm.process_manager[{#POOLNAME}]' delay: '0' trends: '0' value_type: TEXT description: 'The method used by the process manager to control the number of child processes (possible values: ondemand, dynamic or static) for this pool.' preprocessing: - type: JSONPATH parameters: - '$[''process manager'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 53f1f05ed25646d4ab2d5b4860add107 name: 'PHP-FPM ({#POOLNAME}): Slow Requests' type: DEPENDENT key: 'php-fpm.slow_requests[{#POOLNAME}]' delay: '0' description: 'The number of requests that exceeded your request_slowlog_timeout value.' preprocessing: - type: JSONPATH parameters: - '$[''slow requests'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 9c4cd002d5694670926465d5d6253214 name: 'PHP-FPM ({#POOLNAME}): Start Since' type: DEPENDENT key: 'php-fpm.start_since[{#POOLNAME}]' delay: '0' units: s description: 'How long has this pool been running.' preprocessing: - type: JSONPATH parameters: - '$[''start since'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 75d6a5e836924a46b9e60791c4f93403 name: 'PHP-FPM ({#POOLNAME}): Start Time' type: DEPENDENT key: 'php-fpm.start_time[{#POOLNAME}]' delay: '0' units: unixtime description: 'The time when this pool was started.' preprocessing: - type: JSONPATH parameters: - '$[''start time'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 7cd6aaf10b48490aaaf00e338480a5dd name: 'PHP-FPM Pool {#POOLNAME} status page' type: HTTP_AGENT key: 'php-fpm.status[{#POOLNAME}]' delay: 60s trends: '0' value_type: TEXT url: '{$PROTO}://{$HOST.PHPFPM}/fpm-status_{#POOLNAME}?json' follow_redirects: 'NO' tags: - tag: Application value: PHP-FPM - uuid: 9f3388f95c3744829e185575328499d6 name: 'PHP-FPM ({#POOLNAME}): Total Processes' type: DEPENDENT key: 'php-fpm.total_processes[{#POOLNAME}]' delay: '0' description: 'The 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.' preprocessing: - type: JSONPATH parameters: - '$[''total processes'']' master_item: key: 'php-fpm.status[{#POOLNAME}]' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 78ec62cc001542b9a00fd9273a67fe94 name: 'Memory Used by Pool {#POOLNAME}' key: 'proc.mem["php-fpm: pool {#POOLNAME}",,,,pmem]' delay: 120s value_type: FLOAT units: '%' tags: - tag: Application value: PHP-FPM - tag: Application value: 'Pool {#POOLNAME}' - uuid: 2109c5fbb2334b9cb3b4476b7adc7fa0 name: 'Process for pool {#POOLNAME}' key: 'proc.num["php-fpm: pool {#POOLNAME}"]' delay: 60s tags: - tag: Application value: PHP-FPM graph_prototypes: - uuid: 8266542c08ff46a89553cfb52962ea6a name: 'Pool {#POOLNAME} process' ymin_type_1: FIXED graph_items: - drawtype: BOLD_LINE color: 1A7C11 item: host: 'App PHP-FPM' key: 'php-fpm.active_processes[{#POOLNAME}]' - sortorder: '1' drawtype: BOLD_LINE color: F63100 item: host: 'App PHP-FPM' key: 'php-fpm.max_active_processes[{#POOLNAME}]' - sortorder: '2' drawtype: BOLD_LINE color: 2774A4 item: host: 'App PHP-FPM' key: 'php-fpm.total_processes[{#POOLNAME}]' macros: - macro: '{$HOST.PHPFPM}' value: '127.0.0.1:8080' - macro: '{$PROTO}' value: http