zabbix_export:
  version: '7.0'
  template_groups:
    - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
      name: Templates/Applications
  templates:
    - uuid: 49c77ce207f8478da53e761526d6eca5
      template: 'PHP-FPM by HTTP'
      name: 'PHP-FPM by HTTP'
      description: |
        Get PHP-FPM metrics using the Zabbix HTTP agent.
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Applications
      items:
        - uuid: a03bc5c2dc824b8f970ca1d2b7b4637f
          name: 'Accepted connections per second'
          type: DEPENDENT
          key: php-fpm.conn_accepted.rate
          value_type: FLOAT
          description: 'The number of accepted requests per second.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''accepted conn'']'
            - type: CHANGE_PER_SECOND
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: connections
        - uuid: a9ae24915703483ea95a346c625ed70e
          name: 'Get ping page'
          type: HTTP_AGENT
          key: php-fpm.get_ping
          history: '0'
          value_type: TEXT
          url: '{$PHP_FPM.SCHEME}://{$PHP_FPM.HOST}:{$PHP_FPM.PORT}/{$PHP_FPM.PING.PAGE}'
          retrieve_mode: BOTH
          tags:
            - tag: component
              value: health
        - uuid: b91063d42d4b454089b58e29ee3bdb38
          name: 'Get status page'
          type: HTTP_AGENT
          key: php-fpm.get_status
          history: '0'
          value_type: TEXT
          url: '{$PHP_FPM.SCHEME}://{$PHP_FPM.HOST}:{$PHP_FPM.PORT}/{$PHP_FPM.STATUS.PAGE}?json'
          tags:
            - tag: component
              value: raw
        - uuid: cf2fe31db5084bc5b363ef7d0d691c25
          name: 'Listen queue'
          type: DEPENDENT
          key: php-fpm.listen_queue
          description: 'The current number of connections that have been initiated but not yet accepted.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''listen queue'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: listen-queue
        - uuid: 56876a76bd3a4c6c90b033c19a59f6d1
          name: 'Listen queue, len'
          type: DEPENDENT
          key: php-fpm.listen_queue_len
          description: 'The size of the socket queue of pending connections.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''listen queue len'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: listen-queue
        - uuid: a8829ff906e847c2b97a32b1ded60523
          name: 'Listen queue, max'
          type: DEPENDENT
          key: php-fpm.listen_queue_max
          description: 'The maximum number of requests in the queue of pending connections since this FPM pool was started.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''max listen queue'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: listen-queue
        - uuid: 314c3f19311f47acb93b046ab2625c75
          name: 'Queue usage'
          type: CALCULATED
          key: php-fpm.listen_queue_usage
          value_type: FLOAT
          units: '%'
          params: 'last(//php-fpm.listen_queue)/(last(//php-fpm.listen_queue_len)+(last(//php-fpm.listen_queue_len)=0))*100'
          description: 'The utilization of the queue.'
          tags:
            - tag: component
              value: listen-queue
          triggers:
            - uuid: 1ad5018fb19d4a9cb9e627f964bfd627
              expression: 'min(/PHP-FPM by HTTP/php-fpm.listen_queue_usage,15m) > {$PHP_FPM.QUEUE.WARN.MAX}'
              name: 'Queue utilization is high'
              event_name: 'Queue utilization is high (over {$PHP_FPM.QUEUE.WARN.MAX}% for 15m)'
              priority: WARNING
              description: |
                The queue for this pool has reached `{$PHP_FPM.QUEUE.WARN.MAX}%` of its maximum capacity. 
                Items in the queue represent the current number of connections that have been initiated on this pool but not yet accepted.
              tags:
                - tag: scope
                  value: performance
        - uuid: dcb11355c5ae4c6ab5f1326aa1c7bbd6
          name: 'Max children reached'
          type: DEPENDENT
          key: php-fpm.max_children
          description: 'The number of times that `pm.max_children` has been reached since the PHP-FPM pool was started.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''max children reached'']'
            - type: SIMPLE_CHANGE
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: application
        - uuid: 226939bd485a4381a5c0a6d4511acbc3
          name: 'Pool name'
          type: DEPENDENT
          key: php-fpm.name
          value_type: CHAR
          description: 'The name of the current pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.pool
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: application
        - uuid: 6a090c078ace46bd958b42225c63f5ca
          name: Ping
          type: DEPENDENT
          key: php-fpm.ping
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: REGEX
              parameters:
                - '{$PHP_FPM.PING.REPLY}($|\r?\n)'
                - '1'
              error_handler: CUSTOM_VALUE
              error_handler_params: '0'
          master_item:
            key: php-fpm.get_ping
          tags:
            - tag: component
              value: health
          triggers:
            - uuid: 5dcc607026d24e63b2f099540a5d8e9b
              expression: 'last(/PHP-FPM by HTTP/php-fpm.ping)=0 or nodata(/PHP-FPM by HTTP/php-fpm.ping,3m)=1'
              name: 'Service is down'
              priority: HIGH
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: availability
        - uuid: 923243cbb4b647389a38b4788aad3141
          name: 'Processes, active'
          type: DEPENDENT
          key: php-fpm.processes_active
          description: 'The total number of active processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''active processes'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: memory
        - uuid: 79402b0cac4d4a409b39db4bf71557d2
          name: 'Processes, idle'
          type: DEPENDENT
          key: php-fpm.processes_idle
          description: 'The total number of idle processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''idle processes'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: system
        - uuid: 9632f44f9b2648f299e9f61a39daf92f
          name: 'Processes, max active'
          type: DEPENDENT
          key: php-fpm.processes_max_active
          description: 'The highest value of "active processes" since the PHP-FPM server was started.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''max active processes'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: application
        - uuid: e69faadd7a9d457e8f56d283871b946a
          name: 'Processes, total'
          type: DEPENDENT
          key: php-fpm.processes_total
          description: 'The total number of server processes currently running.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''total processes'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: system
        - uuid: 084848b2d6bd4b8a88424b1ec9055b0f
          name: 'Process manager'
          type: DEPENDENT
          key: php-fpm.process_manager
          value_type: CHAR
          description: 'The method used by the process manager to control the number of child processes for this pool.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''process manager'']'
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 8cfa50bcea744075954d0a9c8a132330
              expression: 'last(/PHP-FPM by HTTP/php-fpm.process_manager,#1)<>last(/PHP-FPM by HTTP/php-fpm.process_manager,#2)'
              name: 'Manager changed'
              event_name: 'Manager changed (new value received: {ITEM.VALUE})'
              priority: INFO
              description: 'The PHP-FPM manager has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: 0dd9e388e2584e0090ed65bab39183f9
          name: 'Slow requests'
          type: DEPENDENT
          key: php-fpm.slow_requests
          description: 'The number of requests that has exceeded your `request_slowlog_timeout` value.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''slow requests'']'
            - type: SIMPLE_CHANGE
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: 63bd00ee25af4b42a37dad1d742c66c0
              expression: 'min(/PHP-FPM by HTTP/php-fpm.slow_requests,#3)>0'
              name: 'Detected slow requests'
              priority: WARNING
              description: |
                The PHP-FPM has detected a slow request. 
                The slow request means that it took more time to execute than expected (defined in the configuration of your pool).
              tags:
                - tag: scope
                  value: performance
        - uuid: 9a625629fc0a4222acfefa0409ec1c72
          name: 'Start time'
          type: DEPENDENT
          key: php-fpm.start_time
          units: unixtime
          description: 'The time when this pool was started.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''start time'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: application
        - uuid: 093024c740b946a0bd6637ba9e3e0dad
          name: Uptime
          type: DEPENDENT
          key: php-fpm.uptime
          units: s
          description: 'It indicates how long has this pool been running.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$.[''start since'']'
          master_item:
            key: php-fpm.get_status
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: b44815446b3b464f883f4d0e799b020e
              expression: 'nodata(/PHP-FPM by HTTP/php-fpm.uptime,30m)=1'
              name: 'Failed to fetch info data'
              event_name: 'Failed to fetch info data (or no data for 30m)'
              priority: INFO
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              manual_close: 'YES'
              dependencies:
                - name: 'Service is down'
                  expression: 'last(/PHP-FPM by HTTP/php-fpm.ping)=0 or nodata(/PHP-FPM by HTTP/php-fpm.ping,3m)=1'
              tags:
                - tag: scope
                  value: notice
            - uuid: 9ed4047bdcd74e649814c5d004ba78c7
              expression: 'last(/PHP-FPM by HTTP/php-fpm.uptime)<10m'
              name: 'Pool has been restarted'
              event_name: 'Pool has been restarted (uptime < 10m)'
              priority: INFO
              description: 'Uptime is less than 10 minutes.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: d49adb58e8bb4453911270e5dce1e03e
          name: Version
          type: DEPENDENT
          key: php-fpm.version
          value_type: CHAR
          description: 'The current version of the PHP. You can get it from the HTTP-Header "X-Powered-By"; it may not work if you have changed the default HTTP-headers.'
          preprocessing:
            - type: REGEX
              parameters:
                - '^[.\s\S]*X-Powered-By: PHP/([.\d]{1,})'
                - \1
              error_handler: DISCARD_VALUE
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
          master_item:
            key: php-fpm.get_ping
          tags:
            - tag: component
              value: application
          triggers:
            - uuid: d6c891de92c34bdba80a2ba88f975271
              expression: 'last(/PHP-FPM by HTTP/php-fpm.version,#1)<>last(/PHP-FPM by HTTP/php-fpm.version,#2) and length(last(/PHP-FPM by HTTP/php-fpm.version))>0'
              name: 'Version has changed'
              event_name: 'Version has changed (new version: {ITEM.VALUE})'
              priority: INFO
              description: 'The PHP-FPM version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
      tags:
        - tag: class
          value: application
        - tag: target
          value: php-fpm
      macros:
        - macro: '{$PHP_FPM.HOST}'
          value: localhost
          description: 'The hostname or IP address of the PHP-FPM status for a host or container.'
        - macro: '{$PHP_FPM.PING.PAGE}'
          value: ping
          description: 'The path of the PHP-FPM ping page.'
        - macro: '{$PHP_FPM.PING.REPLY}'
          value: pong
          description: 'The expected reply to the ping.'
        - macro: '{$PHP_FPM.PORT}'
          value: '80'
          description: 'The port of the PHP-FPM status host or container.'
        - macro: '{$PHP_FPM.QUEUE.WARN.MAX}'
          value: '80'
          description: 'The maximum percent of the PHP-FPM queue usage for a trigger expression.'
        - macro: '{$PHP_FPM.SCHEME}'
          value: http
          description: 'Request scheme which may be http or https'
        - macro: '{$PHP_FPM.STATUS.PAGE}'
          value: status
          description: 'The path of the PHP-FPM status page.'
      dashboards:
        - uuid: 3faff0de92724362adda98a08229ef4f
          name: 'PHP-FPM: Overview'
          pages:
            - name: Main
              widgets:
                - type: graph
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PHP-FPM by HTTP'
                        name: 'PHP-FPM: Process'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  x: '36'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'PHP-FPM by HTTP'
                        name: 'PHP-FPM: Queue'
                    - type: STRING
                      name: reference
                      value: AAAAB
      valuemaps:
        - uuid: 8e8fa515c14c4ac181db791c2c68c518
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
  graphs:
    - uuid: 6c69974487f34fea9850ac63fd45adbc
      name: 'PHP-FPM: Process'
      graph_items:
        - color: 199C0D
          item:
            host: 'PHP-FPM by HTTP'
            key: php-fpm.processes_max_active
        - sortorder: '1'
          color: F63100
          item:
            host: 'PHP-FPM by HTTP'
            key: php-fpm.processes_idle
        - sortorder: '2'
          color: 00611C
          item:
            host: 'PHP-FPM by HTTP'
            key: php-fpm.processes_total
        - sortorder: '3'
          color: F7941D
          item:
            host: 'PHP-FPM by HTTP'
            key: php-fpm.processes_active
    - uuid: 250e7f6e07064675872b81a8881f4f31
      name: 'PHP-FPM: Queue'
      graph_items:
        - color: 199C0D
          item:
            host: 'PHP-FPM by HTTP'
            key: php-fpm.listen_queue_len
        - sortorder: '1'
          color: F63100
          item:
            host: 'PHP-FPM by HTTP'
            key: php-fpm.listen_queue
        - sortorder: '2'
          color: 00611C
          item:
            host: 'PHP-FPM by HTTP'
            key: php-fpm.listen_queue_max
