Apache

Apache

The Apache HTTP Server, colloquially called Apache, is a free and open-source cross-platform web server, released under the terms of Apache License 2.0. Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation.

Available solutions




Source: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/apache_agent


Template App Apache by Zabbix agent

Overview

For Zabbix version: 4.4
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 App Apache by Zabbix agent - collects metrics by polling mod_status locally with Zabbix agent:

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_______............................................................................................................................................................................................................................................................................................................

It also uses Zabbix agent to collect Apache Linux process stats like CPU usage, memory usage and whether process is running or not.

This template was tested on:

  • Apache, version 2.4.41

Setup

Setup mod_status

Check module availability: httpd -M 2>/dev/null | grep status_module

Example configuration of Apache:

<Location "/server-status">
  SetHandler server-status
  Require host example.com
</Location>

If you use another path, then don't forget to change {$APACHE.STATUS.PATH} macro. Install and setup Zabbix agent.

Zabbix configuration

No specific Zabbix configuration is required.

Macros used

Name Description Default
{$APACHE.PROCESS_NAME}

Apache server process name

httpd
{$APACHE.RESPONSE_TIME.MAX.WARN}

Maximum Apache response time in seconds for trigger expression

10
{$APACHE.STATUS.HOST}

Hostname or IP address of the Apache status page

127.0.0.1
{$APACHE.STATUS.PATH}

The URL path

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

The port of Apache status page

80

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:

- JSONPATH: $.ServerMPM

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

Items collected

Group Name Description Type Key and additional info
Apache Apache: Service ping

-

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

Preprocessing:

- DISCARD_UNCHANGED_HEARTBEAT: 10m

Apache Apache: Service response time

-

ZABBIX_PASSIVE net.tcp.service.perf[http,"{$APACHE.STATUS.HOST}","{$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: Number of processes running

-

ZABBIX_PASSIVE proc.num["{$APACHE.PROCESS_NAME}"]
Apache Apache: Memory usage (rss)

Resident set size memory used by process in bytes.

ZABBIX_PASSIVE proc.mem["{$APACHE.PROCESS_NAME}",,,,rss]
Apache Apache: Memory usage (vsize)

Virtual memory size used by process in bytes.

ZABBIX_PASSIVE proc.mem["{$APACHE.PROCESS_NAME}",,,,vsize]
Apache Apache: CPU utilization

Process CPU utilization percentage.

ZABBIX_PASSIVE proc.cpu.util["{$APACHE.PROCESS_NAME}"]
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

ZABBIX_PASSIVE web.page.get["{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PATH}","{$APACHE.STATUS.PORT}"]

Preprocessing:

- JAVASCRIPT: // Convert Apache status to JSON var lines = value.split("\n"); var fields = {}, output = {}, workers = { "_": 0, "S": 0, "R": 0, "W": 0, "K": 0, "D": 0, "C": 0, "L": 0, "G": 0, "I": 0, ".": 0 }; // Get all "Key: Value" pairs as an object 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]); } } // For versions without "ServerUptimeSeconds" metric output.ServerUptimeSeconds = output.ServerUptimeSeconds | | output.Uptime // Parse "Scoreboard" to get worker count if (typeof output.Scoreboard === 'string') { for (var i = 0; i < output.Scoreboard.length; i++) { var char = output.Scoreboard[i]; workers[char]++; } } // Add worker data to the output 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 string return JSON.stringify(output);

Triggers

Name Description Expression Severity Dependencies and additional info
Apache: Service is down

-

{TEMPLATE_NAME:net.tcp.service[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"].last()}=0 AVERAGE

Manual close: YES

Depends on:

- Apache: Process is not running

Apache: Service response time is too high (over {$APACHE.RESPONSE_TIME.MAX.WARN}s for 5m)

-

{TEMPLATE_NAME:net.tcp.service.perf[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"].min(5m)}>{$APACHE.RESPONSE_TIME.MAX.WARN} WARNING

Manual close: YES

Depends on:

- Apache: Process is not running

- Apache: Service is down

Apache: has been restarted (uptime < 10m)

Uptime is less than 10 minutes

{TEMPLATE_NAME:apache.uptime.last()}<10m INFO

Manual close: YES

Apache: Version has changed (new version: {ITEM.VALUE})

Apache version has changed. Ack to close.

{TEMPLATE_NAME:apache.version.diff()}=1 and {TEMPLATE_NAME:apache.version.strlen()}>0 INFO

Manual close: YES

Apache: Process is not running

-

{TEMPLATE_NAME:proc.num["{$APACHE.PROCESS_NAME}"].last()}=0 HIGH
Apache: Failed to fetch status page (or no data for 30m)

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

{TEMPLATE_NAME:web.page.get["{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PATH}","{$APACHE.STATUS.PORT}"].nodata(30m)}=1 WARNING

Manual close: YES

Depends on:

- Apache: Process is not running

- 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.

Articles and documentation

+ Propose new article
Add your solution