# Apache by HTTP ## Overview For Zabbix version: 6.2 and higher The template to monitor Apache HTTPD by Zabbix that work without any external scripts. Most of the metrics are collected in one go, thanks to Zabbix bulk data collection. Template `Apache by HTTP` - collects metrics by polling [mod_status](https://httpd.apache.org/docs/current/mod/mod_status.html) with HTTP agent remotely: ```text 127.0.0.1 ServerVersion: Apache/2.4.41 (Unix) ServerMPM: event Server Built: Aug 14 2019 00:35:10 CurrentTime: Friday, 16-Aug-2019 12:38:40 UTC RestartTime: Wednesday, 14-Aug-2019 07:58:26 UTC ParentServerConfigGeneration: 1 ParentServerMPMGeneration: 0 ServerUptimeSeconds: 189613 ServerUptime: 2 days 4 hours 40 minutes 13 seconds Load1: 4.60 Load5: 1.20 Load15: 0.47 Total Accesses: 27860 Total kBytes: 33011 Total Duration: 54118 CPUUser: 18.02 CPUSystem: 31.76 CPUChildrenUser: 0 CPUChildrenSystem: 0 CPULoad: .0262535 Uptime: 189613 ReqPerSec: .146931 BytesPerSec: 178.275 BytesPerReq: 1213.33 DurationPerReq: 1.9425 BusyWorkers: 7 IdleWorkers: 93 Processes: 4 Stopping: 0 BusyWorkers: 7 IdleWorkers: 93 ConnsTotal: 13 ConnsAsyncWriting: 0 ConnsAsyncKeepAlive: 5 ConnsAsyncClosing: 0 Scoreboard: __________________________________________W_____________W___________________LW_____W______W_W_______............................................................................................................................................................................................................................................................................................................ ``` This template was tested on: - Apache, version 2.4.41 ## Setup > See [Zabbix template operation](https://www.zabbix.com/documentation/6.2/manual/config/templates_out_of_the_box/http) for basic instructions. Setup [mod_status](https://httpd.apache.org/docs/current/mod/mod_status.html) Check module availability: `httpd -M 2>/dev/null | grep status_module` Example configuration of Apache: ```text SetHandler server-status Require host example.com ``` If you use another path, then don't forget to change `{$APACHE.STATUS.PATH}` macro. ## Zabbix configuration No specific Zabbix configuration is required. ### Macros used |Name|Description|Default| |----|-----------|-------| |{$APACHE.RESPONSE_TIME.MAX.WARN} |

Maximum Apache response time in seconds for trigger expression

|`10` | |{$APACHE.STATUS.PATH} |

The URL path

|`server-status?auto` | |{$APACHE.STATUS.PORT} |

The port of Apache status page

|`80` | |{$APACHE.STATUS.SCHEME} |

Request scheme which may be http or https

|`http` | ## Template links There are no template links in this template. ## Discovery rules |Name|Description|Type|Key and additional info| |----|-----------|----|----| |Event MPM discovery |

Additional metrics if event MPM is used

https://httpd.apache.org/docs/current/mod/event.html

|DEPENDENT |apache.mpm.event.discovery

**Preprocessing**:

- JAVASCRIPT: `return JSON.stringify(JSON.parse(value).ServerMPM === 'event' ? [{'{#SINGLETON}': ''}] : []);`

- DISCARD_UNCHANGED_HEARTBEAT: `3h`

| ## Items collected |Group|Name|Description|Type|Key and additional info| |-----|----|-----------|----|---------------------| |Apache |Apache: Service ping |

-

|SIMPLE |net.tcp.service[http,"{HOST.CONN}","{$APACHE.STATUS.PORT}"]

**Preprocessing**:

- DISCARD_UNCHANGED_HEARTBEAT: `10m`

| |Apache |Apache: Service response time |

-

|SIMPLE |net.tcp.service.perf[http,"{HOST.CONN}","{$APACHE.STATUS.PORT}"] | |Apache |Apache: Total bytes |

Total bytes served

|DEPENDENT |apache.bytes

**Preprocessing**:

- JSONPATH: `$["Total kBytes"]`

- MULTIPLIER: `1024`

| |Apache |Apache: Bytes per second |

Calculated as change rate for 'Total bytes' stat.

BytesPerSec is not used, as it counts average since last Apache server start.

|DEPENDENT |apache.bytes.rate

**Preprocessing**:

- JSONPATH: `$["Total kBytes"]`

- MULTIPLIER: `1024`

- CHANGE_PER_SECOND

| |Apache |Apache: Requests per second |

Calculated as change rate for 'Total requests' stat.

ReqPerSec is not used, as it counts average since last Apache server start.

|DEPENDENT |apache.requests.rate

**Preprocessing**:

- JSONPATH: `$["Total Accesses"]`

- CHANGE_PER_SECOND

| |Apache |Apache: Total requests |

A total number of accesses

|DEPENDENT |apache.requests

**Preprocessing**:

- JSONPATH: `$["Total Accesses"]`

| |Apache |Apache: Uptime |

Service uptime in seconds

|DEPENDENT |apache.uptime

**Preprocessing**:

- JSONPATH: `$.ServerUptimeSeconds`

| |Apache |Apache: Version |

Service version

|DEPENDENT |apache.version

**Preprocessing**:

- JSONPATH: `$.ServerVersion`

- DISCARD_UNCHANGED_HEARTBEAT: `1d`

| |Apache |Apache: Total workers busy |

Total number of busy worker threads/processes

|DEPENDENT |apache.workers_total.busy

**Preprocessing**:

- JSONPATH: `$.BusyWorkers`

| |Apache |Apache: Total workers idle |

Total number of idle worker threads/processes

|DEPENDENT |apache.workers_total.idle

**Preprocessing**:

- JSONPATH: `$.IdleWorkers`

| |Apache |Apache: Workers closing connection |

Number of workers in closing state

|DEPENDENT |apache.workers.closing

**Preprocessing**:

- JSONPATH: `$.Workers.closing`

| |Apache |Apache: Workers DNS lookup |

Number of workers in dnslookup state

|DEPENDENT |apache.workers.dnslookup

**Preprocessing**:

- JSONPATH: `$.Workers.dnslookup`

| |Apache |Apache: Workers finishing |

Number of workers in finishing state

|DEPENDENT |apache.workers.finishing

**Preprocessing**:

- JSONPATH: `$.Workers.finishing`

| |Apache |Apache: Workers idle cleanup |

Number of workers in cleanup state

|DEPENDENT |apache.workers.cleanup

**Preprocessing**:

- JSONPATH: `$.Workers.cleanup`

| |Apache |Apache: Workers keepalive (read) |

Number of workers in keepalive state

|DEPENDENT |apache.workers.keepalive

**Preprocessing**:

- JSONPATH: `$.Workers.keepalive`

| |Apache |Apache: Workers logging |

Number of workers in logging state

|DEPENDENT |apache.workers.logging

**Preprocessing**:

- JSONPATH: `$.Workers.logging`

| |Apache |Apache: Workers reading request |

Number of workers in reading state

|DEPENDENT |apache.workers.reading

**Preprocessing**:

- JSONPATH: `$.Workers.reading`

| |Apache |Apache: Workers sending reply |

Number of workers in sending state

|DEPENDENT |apache.workers.sending

**Preprocessing**:

- JSONPATH: `$.Workers.sending`

| |Apache |Apache: Workers slot with no current process |

Number of slots with no current process

|DEPENDENT |apache.workers.slot

**Preprocessing**:

- JSONPATH: `$.Workers.slot`

| |Apache |Apache: Workers starting up |

Number of workers in starting state

|DEPENDENT |apache.workers.starting

**Preprocessing**:

- JSONPATH: `$.Workers.starting`

| |Apache |Apache: Workers waiting for connection |

Number of workers in waiting state

|DEPENDENT |apache.workers.waiting

**Preprocessing**:

- JSONPATH: `$.Workers.waiting`

| |Apache |Apache: Connections async closing |

Number of async connections in closing state (only applicable to event MPM)

|DEPENDENT |apache.connections[async_closing{#SINGLETON}]

**Preprocessing**:

- JSONPATH: `$.ConnsAsyncClosing`

| |Apache |Apache: Connections async keep alive |

Number of async connections in keep-alive state (only applicable to event MPM)

|DEPENDENT |apache.connections[async_keep_alive{#SINGLETON}]

**Preprocessing**:

- JSONPATH: `$.ConnsAsyncKeepAlive`

| |Apache |Apache: Connections async writing |

Number of async connections in writing state (only applicable to event MPM)

|DEPENDENT |apache.connections[async_writing{#SINGLETON}]

**Preprocessing**:

- JSONPATH: `$.ConnsAsyncWriting`

| |Apache |Apache: Connections total |

Number of total connections

|DEPENDENT |apache.connections[total{#SINGLETON}]

**Preprocessing**:

- JSONPATH: `$.ConnsTotal`

| |Apache |Apache: Bytes per request |

Average number of client requests per second

|DEPENDENT |apache.bytes[per_request{#SINGLETON}]

**Preprocessing**:

- JSONPATH: `$.BytesPerReq`

| |Apache |Apache: Number of async processes |

Number of async processes

|DEPENDENT |apache.process[num{#SINGLETON}]

**Preprocessing**:

- JSONPATH: `$.Processes`

| |Zabbix raw items |Apache: Get status |

Getting data from a machine-readable version of the Apache status page.

https://httpd.apache.org/docs/current/mod/mod_status.html

|HTTP_AGENT |apache.get_status

**Preprocessing**:

- JAVASCRIPT: `The text is too long. Please see the template.`

| ## Triggers |Name|Description|Expression|Severity|Dependencies and additional info| |----|-----------|----|----|----| |Apache: Service is down |

-

|`last(/Apache by HTTP/net.tcp.service[http,"{HOST.CONN}","{$APACHE.STATUS.PORT}"])=0` |AVERAGE |

Manual close: YES

| |Apache: Service response time is too high |

-

|`min(/Apache by HTTP/net.tcp.service.perf[http,"{HOST.CONN}","{$APACHE.STATUS.PORT}"],5m)>{$APACHE.RESPONSE_TIME.MAX.WARN}` |WARNING |

Manual close: YES

**Depends on**:

- Apache: Service is down

| |Apache: has been restarted |

Uptime is less than 10 minutes.

|`last(/Apache by HTTP/apache.uptime)<10m` |INFO |

Manual close: YES

| |Apache: Version has changed |

Apache version has changed. Ack to close.

|`last(/Apache by HTTP/apache.version,#1)<>last(/Apache by HTTP/apache.version,#2) and length(last(/Apache by HTTP/apache.version))>0` |INFO |

Manual close: YES

| |Apache: Failed to fetch status page |

Zabbix has not received data for items for the last 30 minutes.

|`nodata(/Apache by HTTP/apache.get_status,30m)=1` |WARNING |

Manual close: YES

**Depends on**:

- Apache: Service is down

| ## Feedback Please report any issues with the template at https://support.zabbix.com You can also provide feedback, discuss the template or ask for help with it at [ZABBIX forums](https://www.zabbix.com/forum/zabbix-suggestions-and-feedback/384764-discussion-thread-for-official-zabbix-template-apache).