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 - (Zabbix version >= 4.2) - 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

NameDescriptionDefault
{$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

NameDescriptionTypeKey and additional info
Event MPM discovery

Additional metrics if event MPM is used

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

DEPENDENTapache.mpm.event.discovery

Preprocessing:

- JSONPATH: $.ServerMPM

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

Items collected

GroupNameDescriptionTypeKey and additional info
ApacheApache: Service ping

-

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

Preprocessing:

- DISCARD_UNCHANGED_HEARTBEAT: 10m

ApacheApache: Service response time

-

ZABBIX_PASSIVEnet.tcp.service.perf[http,"{$APACHE.STATUS.HOST}","{$APACHE.STATUS.PORT}"]
ApacheApache: Total bytes

Total bytes served

DEPENDENTapache.bytes

Preprocessing:

- JSONPATH: $["Total kBytes"]

- MULTIPLIER: 1024

ApacheApache: Bytes per second

Calculated as change rate for 'Total bytes' stat.

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

DEPENDENTapache.bytes.rate

Preprocessing:

- JSONPATH: $["Total kBytes"]

- MULTIPLIER: 1024

- CHANGE_PER_SECOND

ApacheApache: Requests per second

Calculated as change rate for 'Total requests' stat.

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

DEPENDENTapache.requests.rate

Preprocessing:

- JSONPATH: $["Total Accesses"]

- CHANGE_PER_SECOND

ApacheApache: Total requests

A total number of accesses

DEPENDENTapache.requests

Preprocessing:

- JSONPATH: $["Total Accesses"]

ApacheApache: Uptime

Service uptime in seconds

DEPENDENTapache.uptime

Preprocessing:

- JSONPATH: $.ServerUptimeSeconds

ApacheApache: Version

Service version

DEPENDENTapache.version

Preprocessing:

- JSONPATH: $.ServerVersion

- DISCARD_UNCHANGED_HEARTBEAT: 1d

ApacheApache: Total workers busy

Total number of busy worker threads/processes

DEPENDENTapache.workers_total.busy

Preprocessing:

- JSONPATH: $.BusyWorkers

ApacheApache: Total workers idle

Total number of idle worker threads/processes

DEPENDENTapache.workers_total.idle

Preprocessing:

- JSONPATH: $.IdleWorkers

ApacheApache: Workers closing connection

Number of workers in closing state

DEPENDENTapache.workers.closing

Preprocessing:

- JSONPATH: $.Workers.closing

ApacheApache: Workers DNS lookup

Number of workers in dnslookup state

DEPENDENTapache.workers.dnslookup

Preprocessing:

- JSONPATH: $.Workers.dnslookup

ApacheApache: Workers finishing

Number of workers in finishing state

DEPENDENTapache.workers.finishing

Preprocessing:

- JSONPATH: $.Workers.finishing

ApacheApache: Workers idle cleanup

Number of workers in cleanup state

DEPENDENTapache.workers.cleanup

Preprocessing:

- JSONPATH: $.Workers.cleanup

ApacheApache: Workers keepalive (read)

Number of workers in keepalive state

DEPENDENTapache.workers.keepalive

Preprocessing:

- JSONPATH: $.Workers.keepalive

ApacheApache: Workers logging

Number of workers in logging state

DEPENDENTapache.workers.logging

Preprocessing:

- JSONPATH: $.Workers.logging

ApacheApache: Workers reading request

Number of workers in reading state

DEPENDENTapache.workers.reading

Preprocessing:

- JSONPATH: $.Workers.reading

ApacheApache: Workers sending reply

Number of workers in sending state

DEPENDENTapache.workers.sending

Preprocessing:

- JSONPATH: $.Workers.sending

ApacheApache: Workers slot with no current process

Number of slots with no current process

DEPENDENTapache.workers.slot

Preprocessing:

- JSONPATH: $.Workers.slot

ApacheApache: Workers starting up

Number of workers in starting state

DEPENDENTapache.workers.starting

Preprocessing:

- JSONPATH: $.Workers.starting

ApacheApache: Workers waiting for connection

Number of workers in waiting state

DEPENDENTapache.workers.waiting

Preprocessing:

- JSONPATH: $.Workers.waiting

ApacheApache: Number of processes running

-

ZABBIX_PASSIVEproc.num["{$APACHE.PROCESS_NAME}"]
ApacheApache: Memory usage (rss)

Resident set size memory used by process in bytes.

ZABBIX_PASSIVEproc.mem["{$APACHE.PROCESS_NAME}",,,,rss]
ApacheApache: Memory usage (vsize)

Virtual memory size used by process in bytes.

ZABBIX_PASSIVEproc.mem["{$APACHE.PROCESS_NAME}",,,,vsize]
ApacheApache: CPU utilization

Process CPU utilization percentage.

ZABBIX_PASSIVEproc.cpu.util["{$APACHE.PROCESS_NAME}"]
ApacheApache: Connections async closing

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

DEPENDENTapache.connections[async_closing{ #SINGLETON}]

Preprocessing:

- JSONPATH: $.ConnsAsyncClosing

ApacheApache: Connections async keep alive

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

DEPENDENTapache.connections[async_keep_alive{ #SINGLETON}]

Preprocessing:

- JSONPATH: $.ConnsAsyncKeepAlive

ApacheApache: Connections async writing

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

DEPENDENTapache.connections[async_writing{ #SINGLETON}]

Preprocessing:

- JSONPATH: $.ConnsAsyncWriting

ApacheApache: Connections total

Number of total connections

DEPENDENTapache.connections[total{ #SINGLETON}]

Preprocessing:

- JSONPATH: $.ConnsTotal

ApacheApache: Bytes per request

Average number of client requests per second

DEPENDENTapache.bytes[per_request{ #SINGLETON}]

Preprocessing:

- JSONPATH: $.BytesPerReq

ApacheApache: Number of async processes

Number of async processes

DEPENDENTapache.process[num{ #SINGLETON}]

Preprocessing:

- JSONPATH: $.Processes

Zabbix_raw_itemsApache: 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_PASSIVEweb.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

Triggers

NameDescriptionExpressionSeverityDependencies and additional info
Apache: Service is down

-

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

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()}<10mINFO

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()}>0INFO

Manual close: YES

Apache: Process is not running

-

{TEMPLATE_NAME:proc.num["{$APACHE.PROCESS_NAME}"].last()}=0HIGH
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)}=1WARNING

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