Page tree
Skip to end of metadata
Go to start of metadata

Apache monitoring

Apache httpd server of current latest version(2.4.25) provides status page "by default". It is mapped to path /server-status and looks rather informative. Monitoring plugin will use this page with param auto (/server-status?auto) which gives same data in more parse-friendly way.

It looks like this:

localhost
ServerVersion: Apache/2.4.25 (Ubuntu)
ServerMPM: event
Server Built: 2017-02-10T16:53:43
CurrentTime: Wednesday, 14-Jun-2017 07:46:49 EEST
RestartTime: Wednesday, 14-Jun-2017 07:46:42 EEST
ParentServerConfigGeneration: 1
ParentServerMPMGeneration: 0
ServerUptimeSeconds: 6
ServerUptime: 6 seconds
Load1: 0.88
Load5: 0.57
Load15: 0.48
BusyWorkers: 1
IdleWorkers: 49
ConnsTotal: 0
ConnsAsyncWriting: 0
ConnsAsyncKeepAlive: 0
ConnsAsyncClosing: 0
Scoreboard: ______________________________________W_________....................................................................................................

Or, with "ExtendedStatus On" in apache2.conf, like this:

localhost
ServerVersion: Apache/2.4.25 (Ubuntu)
ServerMPM: event
Server Built: 2017-02-10T16:53:43
CurrentTime: Wednesday, 14-Jun-2017 07:53:42 EEST
RestartTime: Wednesday, 14-Jun-2017 07:53:13 EEST
ParentServerConfigGeneration: 1
ParentServerMPMGeneration: 0
ServerUptimeSeconds: 28
ServerUptime: 28 seconds
Load1: 1.08
Load5: 0.98
Load15: 0.72
Total Accesses: 45
Total kBytes: 67
CPUUser: .03
CPUSystem: .02
CPUChildrenUser: 0
CPUChildrenSystem: 0
CPULoad: .178571
Uptime: 28
ReqPerSec: 1.60714
BytesPerSec: 2450.29
BytesPerReq: 1524.62
BusyWorkers: 1
IdleWorkers: 49
ConnsTotal: 1
ConnsAsyncWriting: 0
ConnsAsyncKeepAlive: 1
ConnsAsyncClosing: 0
Scoreboard: ________________________________________W_______....................................................................................................

Second variant gives us some new useful metrics: Total Accesses(and we easily calculate req/sec from this), Total kBytes(and we calculate kBytes/sec), CPU usage metrics.

ReqPerSec/BytesPerSec/BytesPerReq are rather useless(and parser in plugin ignores them)  as they are calculated for the whole uptime of apache server.

(warning) Apache shows that in further versions(in 2.4.7 at least, as in demo at http://www.apache.org/server-status?view=json | http://www.apache.org/server-status) server status module will be changed enough to write additional parser for apache status page.

Integration

Integration with MoSKito is done in form of generic plugin that is able to monitor apache/nginx/other similar apps.
This plugin is located in maven module moskito-extensions/moskito-monitoring-plugin/.

If needed, add it as a maven dependency:

<dependency>
    <groupId>net.anotheria</groupId>
    <artifactId>moskito-monitoring-plugin</artifactId>
    <version>${project.version}</version>
</dependency>


To enable plugin, add next lines to @pluginsConfig section in moskito.json file:

plugins section in moskito.json
"@pluginsConfig": {
        "@plugins": [
          .....
          {
            "name": "ApacheMonitoringPlugin",
            "configurationName": "monitoring-plugin-apache",
            "className": "net.anotheria.moskito.extensions.monitoring.GenericMonitoringPlugin"
          }
          .....
        ]
    }

You can add several instances of plugin, configured with different config files - they wont interfere if you use different names for "monitored instances", see section below.

Configuration

Now you have to configure monitored nginx instances in monitoring-plugin-apache.json file(if you haven't changed configurationName in plugins section):

monitoring-plugin-apache.json
{
  "pluginType": "apache",
  "@monitoredInstances": [],
  "@metrics": [],

  "dev": {
    "dzhmud": {
      "@metrics": ["Hostname","Accesses","Total kB","Req/sec","KBytes/sec","Busy","Idle","Uptime(sec)","Uptime","CPU load","CPU user","CPU system","CPU user(children).","CPU system(children).","Load 1m","Load 5m","Load 15m","Con(total)","Con(writing)","Con(keepAlive)","Con(closing)","SB S","SB R","SB W","SB K","SB L","SB D","SB C","SB G","SB I","SB .","SB _","SB total"],
      "@monitoredInstances": [
        {
          "name": "localhost_apache_at_9080",
          "location": "http://localhost:9080/server-status?auto",
          "username": "",
          "password": ""
        }
      ]
    }
  }
}

Make sure that line "pluginType": "apache" is present - the plugin itself is rather generic and here is the place you tell it which type of plugin it should be.

Monitored instances can be added/deleted/changed at runtime. Duplicate names are not allowed - if found, duplicates will be ignored. Currently names are directly used as created producers IDs, so names should be rather unique and don't interfere with other moskito producers.

Username/password can be omitted if not needed.
"@metrics" property can be used to instruct plugin which metrics it should monitor. If this property is absent or empty, all available metrics will be used. If property is present, and some metrics are ignored, "Uptime(sec)" metric will remain monitored in any case, as it is used for checking apache server restarts. Sample above contains all currently available metrics.

Apache metrics

Metric name

Description

Hostname

Apache hostname.

Accesses

Total accesses(requests).

Total kB

Total kilobytes served.

Req/sec

Requests per second. Calculated from 'Accesses' metric, as apache calculates it for the whole uptime.

KBytes/sec

KBytes per second. Calculated from 'Total kB' metric, as apache calculates it for the whole uptime.

Busy

Number of busy workers/threads.

Idle

Number of idle workers/threads.

Uptime(sec)

Server uptime in seconds.

Uptime

Server uptime in human-readable form.

CPU load

CPU Load, in percents. Total CPU time utilized by apache divided by uptime.

CPU user

CPU time utilized by apache at user level.

CPU system

CPU time utilized by apache at system(kernel) level.

CPU user(children).

CPU time utilized by apache child workers at user level.

CPU system(children).

CPU time utilized by apache child workers at system(kernel) level.

Load 1m

Unix 'load-average' of the host system.

Load 5m

Unix 'load-average' of the host system.

Load 15m

Unix 'load-average' of the host system.

Con(total)

Current number of connections.

Con(writing)

Async connection writing.

Con(keepAlive)

Async keeped alive connections.

Con(closing)

Async closed connections.

SB S

Number of busy workers that are starting up.

SB R

Number of busy workers that are reading request.

SB W

Number of busy workers that are sending reply(writing).

SB K

Number of busy workers that are in 'keep-alive' state.

SB L

Number of busy workers that are logging.

SB D

Number of busy workers that are doing DNS lookup.

SB C

Number of busy workers that are closing connection.

SB G

Number of busy workers that are gracefully finishing(read about graceful restart).

SB I

Number of busy workers that are in 'idle cleanup' state.

SB .

Number of open slots with no worker running(but configuration allows it to be started).

SB _

Number of currently idle(waiting for connections) workers.

SB total

Maximum number of worker threads.


Run MoSKito

Run MoSKito and find new producers under Apache section in producers list.

  • No labels