zabbix_export:
  version: '7.0'
  template_groups:
    - uuid: a571c0d144b14fd4a87a9d9b2aa9fcd6
      name: Templates/Applications
  templates:
    - uuid: 86702e8bc514434e8c914d50c206cb94
      template: 'Apache by HTTP'
      name: 'Apache by HTTP'
      description: |
        This template is designed for the effortless deployment of Apache monitoring by Zabbix via HTTP and doesn't require any external scripts.
        
        The template collects metrics by polling 'mod_status' with HTTP agent remotely.
        
        Setup:
        
        1. See the setup instructions for mod_status:
        https://httpd.apache.org/docs/current/mod/mod_status.html
        
        Check the availability of the module with this command line:
        httpd -M 2>/dev/null | grep status_module
        
        This is an example configuration of the Apache web server:
        
        <Location "/server-status">
          SetHandler server-status
          Require host example.com
        </Location>
        
        2. Set the hostname or IP address of the Apache status page host in the '{$APACHE.STATUS.HOST}' macro. You can also change the status page port in the '{$APACHE.STATUS.PORT}' macro and status page path in the '{$APACHE.STATUS.PATH}' macro if necessary.
        
        You can discuss this template or leave feedback on our forum https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384764-discussion-thread-for-official-zabbix-template-apache
        
        Generated by official Zabbix template tool "Templator"
      vendor:
        name: Zabbix
        version: 7.0-0
      groups:
        - name: Templates/Applications
      items:
        - uuid: b9fe6f0bbe174e9f81af84a3bc0b0e7c
          name: 'Total bytes'
          type: DEPENDENT
          key: apache.bytes
          value_type: FLOAT
          units: B
          description: 'The total bytes served.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["Total kBytes"]'
            - type: MULTIPLIER
              parameters:
                - '1024'
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: network
        - uuid: b36010be10874cf188eeacc81f2c366f
          name: 'Bytes per second'
          type: DEPENDENT
          key: apache.bytes.rate
          value_type: FLOAT
          units: Bps
          description: |
            It is calculated as a rate of change for total bytes statistics.
            `BytesPerSec` is not used, as it counts the average since the last Apache server start.
            
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["Total kBytes"]'
            - type: MULTIPLIER
              parameters:
                - '1024'
            - type: CHANGE_PER_SECOND
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: network
        - uuid: e61be8ad92004100aca55fcedd2a3807
          name: 'Get status'
          type: HTTP_AGENT
          key: apache.get_status
          history: 1h
          value_type: TEXT
          description: |
            Getting data from a machine-readable version of the Apache status page.
            For more information see Apache Module [mod_status](https://httpd.apache.org/docs/current/mod/mod_status.html).
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  var lines = value.split('\n');
                  var output = {},
                  	workers = {
                  		'_': 0, 'S': 0, 'R': 0, 'W': 0,
                  		'K': 0, 'D': 0, 'C': 0, 'L': 0,
                  		'G': 0, 'I': 0, '.': 0
                  	};
                  
                  for (var i = 0; i < lines.length; i++) {
                  	var line = lines[i].match(/([A-z0-9 ]+): (.*)/);
                  
                  	if (line !== null) {
                  		output[line[1]] = isNaN(line[2]) ? line[2] : Number(line[2]);
                  	}
                  }
                  
                  output.ServerUptimeSeconds = output.ServerUptimeSeconds || output.Uptime;
                  output.ServerVersion = output.ServerVersion || output.Server;
                  
                  if (typeof output.Scoreboard === 'string') {
                  	for (var i = 0; i < output.Scoreboard.length; i++) {
                  		var char = output.Scoreboard[i];
                  
                  		workers[char]++;
                  	}
                  }
                  
                  output.Workers = {
                  	waiting: workers['_'], starting: workers['S'], reading: workers['R'],
                  	sending: workers['W'], keepalive: workers['K'], dnslookup: workers['D'],
                  	closing: workers['C'], logging: workers['L'], finishing: workers['G'],
                  	cleanup: workers['I'], slot: workers['.']
                  };
                  
                  return JSON.stringify(output);
          url: '{$APACHE.STATUS.SCHEME}://{$APACHE.STATUS.HOST}:{$APACHE.STATUS.PORT}/{$APACHE.STATUS.PATH}'
          retrieve_mode: BOTH
          tags:
            - tag: component
              value: raw
          triggers:
            - uuid: db396445cc5042f89f31dc12cb99c32e
              expression: 'nodata(/Apache by HTTP/apache.get_status,30m)=1'
              name: 'Failed to fetch status page'
              event_name: 'Failed to fetch status page (or no data for 30m)'
              priority: WARNING
              description: 'Zabbix has not received any data for items for the last 30 minutes.'
              manual_close: 'YES'
              dependencies:
                - name: 'Service is down'
                  expression: 'last(/Apache by HTTP/net.tcp.service[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"])=0'
              tags:
                - tag: scope
                  value: availability
        - uuid: 5fb5101de70a43fab50d55f418462255
          name: 'Total requests'
          type: DEPENDENT
          key: apache.requests
          description: 'The total number of the Apache server accesses.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["Total Accesses"]'
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: network
        - uuid: ee15f4958040459da53251cc3561ed39
          name: 'Requests per second'
          type: DEPENDENT
          key: apache.requests.rate
          value_type: FLOAT
          description: |
            It is calculated as a rate of change for the "Total requests" statistics.
            `ReqPerSec` is not used, as it counts the average since the last Apache server start.
          preprocessing:
            - type: JSONPATH
              parameters:
                - '$["Total Accesses"]'
            - type: CHANGE_PER_SECOND
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: network
        - uuid: 3dd8ba505d584b028c7ac08d8b959eb3
          name: Uptime
          type: DEPENDENT
          key: apache.uptime
          units: uptime
          description: 'The service uptime expressed in seconds.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ServerUptimeSeconds
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 76cfa6ebf39f4c8fbd8fde9e0f36d3ed
              expression: 'last(/Apache by HTTP/apache.uptime)<10m'
              name: 'Host has been restarted'
              event_name: '{HOST.NAME} has been restarted (uptime < 10m)'
              priority: INFO
              description: 'Uptime is less than 10 minutes.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: fe0de2eb1478482f99b38c13bd20564c
          name: Version
          type: DEPENDENT
          key: apache.version
          value_type: CHAR
          description: 'The Apache service version.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.ServerVersion
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 1d
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
          triggers:
            - uuid: 5296d69af0704d0e8a07398f0b4c9685
              expression: 'last(/Apache by HTTP/apache.version,#1)<>last(/Apache by HTTP/apache.version,#2) and length(last(/Apache by HTTP/apache.version))>0'
              name: 'Version has changed'
              event_name: 'Version has changed (new version: {ITEM.VALUE})'
              priority: INFO
              description: 'Apache version has changed. Acknowledge to close the problem manually.'
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: notice
        - uuid: f74ffb92e30e48958b5b82f7dfbe5147
          name: 'Workers idle cleanup'
          type: DEPENDENT
          key: apache.workers.cleanup
          description: 'The number of workers in cleanup state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.cleanup
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: d664bee9a330480bbaee7273b871a8d3
          name: 'Workers closing connection'
          type: DEPENDENT
          key: apache.workers.closing
          description: 'The number of workers in closing state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.closing
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: a6fb3444585749be998ec840cd8e4511
          name: 'Workers DNS lookup'
          type: DEPENDENT
          key: apache.workers.dnslookup
          description: 'The number of workers in `dnslookup` state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.dnslookup
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: fcf771f2a9b64a81a37db679f0494ed3
          name: 'Workers finishing'
          type: DEPENDENT
          key: apache.workers.finishing
          description: 'The number of workers in finishing state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.finishing
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: cb81a6a77395444283bc5e065fcbfc2e
          name: 'Workers keepalive (read)'
          type: DEPENDENT
          key: apache.workers.keepalive
          description: 'The number of workers in `keepalive` state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.keepalive
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: 7fc0002a279b4541af569a03c1aca2ac
          name: 'Workers logging'
          type: DEPENDENT
          key: apache.workers.logging
          description: 'The number of workers in logging state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.logging
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: 78b0bd7d8bec49549fc003d460af9177
          name: 'Workers reading request'
          type: DEPENDENT
          key: apache.workers.reading
          description: 'The number of workers in reading state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.reading
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: 379ac66397b94463ad17b24fbd20c615
          name: 'Workers sending reply'
          type: DEPENDENT
          key: apache.workers.sending
          description: 'The number of workers in sending state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.sending
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: 1c90055e02a244fc8d18e73b23daa0f1
          name: 'Workers slot with no current process'
          type: DEPENDENT
          key: apache.workers.slot
          description: 'The number of slots with no current process.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.slot
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: ae21ea113e8840349aff81ab582d92b4
          name: 'Workers starting up'
          type: DEPENDENT
          key: apache.workers.starting
          description: 'The number of workers in starting state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.starting
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: be1a05a6eab84b64ac4d51c966ea91e8
          name: 'Workers waiting for connection'
          type: DEPENDENT
          key: apache.workers.waiting
          description: 'The number of workers in waiting state.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.Workers.waiting
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: 1752b9bcf7b34abbaf105f5261638271
          name: 'Total workers busy'
          type: DEPENDENT
          key: apache.workers_total.busy
          description: 'The total number of busy worker threads/processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.BusyWorkers
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: b1b1c86a12964ae2813c63481e464ec7
          name: 'Total workers idle'
          type: DEPENDENT
          key: apache.workers_total.idle
          description: 'The total number of idle worker threads/processes.'
          preprocessing:
            - type: JSONPATH
              parameters:
                - $.IdleWorkers
          master_item:
            key: apache.get_status
          tags:
            - tag: component
              value: system
        - uuid: 5039d11bc3964d6e9928a0a46dd0b402
          name: 'Service response time'
          type: SIMPLE
          key: 'net.tcp.service.perf[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"]'
          value_type: FLOAT
          units: s
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: ffbb564032c7462eb0bb9b4c2f700559
              expression: 'min(/Apache by HTTP/net.tcp.service.perf[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"],5m)>{$APACHE.RESPONSE_TIME.MAX.WARN}'
              name: 'Service response time is too high'
              event_name: 'Service response time is too high (over {$APACHE.RESPONSE_TIME.MAX.WARN}s for 5m)'
              priority: WARNING
              manual_close: 'YES'
              dependencies:
                - name: 'Service is down'
                  expression: 'last(/Apache by HTTP/net.tcp.service[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"])=0'
              tags:
                - tag: scope
                  value: performance
        - uuid: fb65918695094026838e2b9e4ca00402
          name: 'Service ping'
          type: SIMPLE
          key: 'net.tcp.service[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"]'
          valuemap:
            name: 'Service state'
          preprocessing:
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 10m
          tags:
            - tag: component
              value: application
            - tag: component
              value: health
          triggers:
            - uuid: afe2fde35d054333adc8369a0f9af778
              expression: 'last(/Apache by HTTP/net.tcp.service[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"])=0'
              name: 'Service is down'
              priority: AVERAGE
              manual_close: 'YES'
              tags:
                - tag: scope
                  value: availability
      discovery_rules:
        - uuid: eee8abd3174d426092e8bca9b3ba982e
          name: 'Event MPM discovery'
          type: DEPENDENT
          key: apache.mpm.event.discovery
          description: |
            The discovery of additional metrics if the event Multi-Processing Module (MPM) is used.
            For more details see [Apache MPM event](https://httpd.apache.org/docs/current/mod/event.html).
          item_prototypes:
            - uuid: f52700379f9a4ee8b378a2eb9caea070
              name: 'Bytes per request'
              type: DEPENDENT
              key: 'apache.bytes[per_request{#SINGLETON}]'
              value_type: FLOAT
              units: B
              description: 'The average number of client requests per second.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.BytesPerReq
              master_item:
                key: apache.get_status
              tags:
                - tag: component
                  value: connection
            - uuid: 062d7c941f0c468d8b63fa76ae0610f6
              name: 'Connections async closing'
              type: DEPENDENT
              key: 'apache.connections[async_closing{#SINGLETON}]'
              description: 'The number of asynchronous connections in closing state (applicable only to the event MPM).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.ConnsAsyncClosing
              master_item:
                key: apache.get_status
              tags:
                - tag: component
                  value: connection
            - uuid: 6cb8b255ad8343a48e622912bc298366
              name: 'Connections async keepalive'
              type: DEPENDENT
              key: 'apache.connections[async_keep_alive{#SINGLETON}]'
              description: 'The number of asynchronous connections in keepalive state (applicable only to the event MPM).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.ConnsAsyncKeepAlive
              master_item:
                key: apache.get_status
              tags:
                - tag: component
                  value: connection
            - uuid: 997b3452aac24ad6afbad775d649c727
              name: 'Connections async writing'
              type: DEPENDENT
              key: 'apache.connections[async_writing{#SINGLETON}]'
              description: 'The number of asynchronous connections in writing state (applicable only to the event MPM).'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.ConnsAsyncWriting
              master_item:
                key: apache.get_status
              tags:
                - tag: component
                  value: connection
            - uuid: 31cb044eed904ca19150921fe36f3285
              name: 'Connections total'
              type: DEPENDENT
              key: 'apache.connections[total{#SINGLETON}]'
              description: 'The number of total connections.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.ConnsTotal
              master_item:
                key: apache.get_status
              tags:
                - tag: component
                  value: connection
            - uuid: 34555340f3ad4b878504df188f54a9c9
              name: 'Number of async processes'
              type: DEPENDENT
              key: 'apache.process[num{#SINGLETON}]'
              description: 'The number of asynchronous processes.'
              preprocessing:
                - type: JSONPATH
                  parameters:
                    - $.Processes
              master_item:
                key: apache.get_status
              tags:
                - tag: component
                  value: system
          graph_prototypes:
            - uuid: 066b53ed2244414ca3090498eb035c27
              name: 'Apache: Current async connections{#SINGLETON}'
              graph_items:
                - color: 199C0D
                  item:
                    host: 'Apache by HTTP'
                    key: 'apache.connections[async_closing{#SINGLETON}]'
                - sortorder: '1'
                  color: F63100
                  item:
                    host: 'Apache by HTTP'
                    key: 'apache.connections[async_keep_alive{#SINGLETON}]'
                - sortorder: '2'
                  color: 00611C
                  item:
                    host: 'Apache by HTTP'
                    key: 'apache.connections[async_writing{#SINGLETON}]'
                - sortorder: '3'
                  drawtype: BOLD_LINE
                  color: F7941D
                  item:
                    host: 'Apache by HTTP'
                    key: 'apache.connections[total{#SINGLETON}]'
            - uuid: dbaa0c2468cc40fca977fb382d19cb78
              name: 'Apache: Current async processes{#SINGLETON}'
              graph_items:
                - drawtype: GRADIENT_LINE
                  color: 199C0D
                  item:
                    host: 'Apache by HTTP'
                    key: 'apache.process[num{#SINGLETON}]'
          master_item:
            key: apache.get_status
          preprocessing:
            - type: JAVASCRIPT
              parameters:
                - |
                  return JSON.stringify(JSON.parse(value).ServerMPM === 'event'
                  	? [{'{#SINGLETON}': ''}] : []);
            - type: DISCARD_UNCHANGED_HEARTBEAT
              parameters:
                - 3h
      tags:
        - tag: class
          value: software
        - tag: target
          value: apache
      macros:
        - macro: '{$APACHE.RESPONSE_TIME.MAX.WARN}'
          value: '10'
          description: 'The maximum Apache response time expressed in seconds for a trigger expression.'
        - macro: '{$APACHE.STATUS.HOST}'
          value: '<SET APACHE HOST>'
          description: 'The hostname or IP address of the Apache status page host.'
        - macro: '{$APACHE.STATUS.PATH}'
          value: 'server-status?auto'
          description: 'The URL path.'
        - macro: '{$APACHE.STATUS.PORT}'
          value: '80'
          description: 'The port of the Apache status page.'
        - macro: '{$APACHE.STATUS.SCHEME}'
          value: http
          description: 'The request scheme, which may be either HTTP or HTTPS.'
      dashboards:
        - uuid: a328c9e713424465a8e1adec7322b0dc
          name: 'Apache performance'
          pages:
            - name: General
              widgets:
                - type: graph
                  width: '72'
                  height: '7'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Apache by HTTP'
                        name: 'Apache: Worker states'
                    - type: STRING
                      name: reference
                      value: AAAAA
                - type: graph
                  'y': '7'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Apache by HTTP'
                        name: 'Apache: Requests per second'
                    - type: STRING
                      name: reference
                      value: AAAAB
                - type: graphprototype
                  'y': '12'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Apache by HTTP'
                        name: 'Apache: Current async connections{#SINGLETON}'
                    - type: STRING
                      name: reference
                      value: AAAAD
                - type: graph
                  x: '36'
                  'y': '7'
                  width: '36'
                  height: '5'
                  fields:
                    - type: GRAPH
                      name: graphid.0
                      value:
                        host: 'Apache by HTTP'
                        name: 'Apache: Workers total'
                    - type: STRING
                      name: reference
                      value: AAAAC
                - type: graphprototype
                  x: '36'
                  'y': '12'
                  width: '36'
                  height: '5'
                  fields:
                    - type: INTEGER
                      name: columns
                      value: '1'
                    - type: GRAPH_PROTOTYPE
                      name: graphid.0
                      value:
                        host: 'Apache by HTTP'
                        name: 'Apache: Current async processes{#SINGLETON}'
                    - type: STRING
                      name: reference
                      value: AAAAE
      valuemaps:
        - uuid: a5d1f911fb264bd4bc087ea582626d7f
          name: 'Service state'
          mappings:
            - value: '0'
              newvalue: Down
            - value: '1'
              newvalue: Up
  graphs:
    - uuid: a3998992f7504a12826e3c4d592836b5
      name: 'Apache: Requests per second'
      graph_items:
        - drawtype: GRADIENT_LINE
          color: 199C0D
          item:
            host: 'Apache by HTTP'
            key: apache.requests.rate
    - uuid: 1629062b5cd74b67af9a60226a79f8f1
      name: 'Apache: Worker states'
      graph_items:
        - color: 199C0D
          item:
            host: 'Apache by HTTP'
            key: apache.workers.dnslookup
        - sortorder: '1'
          color: F63100
          item:
            host: 'Apache by HTTP'
            key: apache.workers.cleanup
        - sortorder: '2'
          color: 00611C
          item:
            host: 'Apache by HTTP'
            key: apache.workers.logging
        - sortorder: '3'
          color: F7941D
          item:
            host: 'Apache by HTTP'
            key: apache.workers.reading
        - sortorder: '4'
          color: FC6EA3
          item:
            host: 'Apache by HTTP'
            key: apache.workers.sending
        - sortorder: '5'
          color: 6C59DC
          item:
            host: 'Apache by HTTP'
            key: apache.workers.starting
        - sortorder: '6'
          color: C7A72D
          item:
            host: 'Apache by HTTP'
            key: apache.workers.closing
        - sortorder: '7'
          color: BA2A5D
          item:
            host: 'Apache by HTTP'
            key: apache.workers.finishing
        - sortorder: '8'
          color: F230E0
          item:
            host: 'Apache by HTTP'
            key: apache.workers.keepalive
        - sortorder: '9'
          color: 5CCD18
          item:
            host: 'Apache by HTTP'
            key: apache.workers.slot
        - sortorder: '10'
          color: BB2A02
          item:
            host: 'Apache by HTTP'
            key: apache.workers.waiting
    - uuid: 78e59f1b5eb747019f92921ac5ef48b0
      name: 'Apache: Workers total'
      type: STACKED
      graph_items:
        - color: 199C0D
          item:
            host: 'Apache by HTTP'
            key: apache.workers_total.busy
        - sortorder: '1'
          color: F63100
          item:
            host: 'Apache by HTTP'
            key: apache.workers_total.idle
