aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/apache.php
blob: 60371edd65307423680ac14a98e9f410825d3e9a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php

# Collectd Apache plugin

require_once 'conf/common.inc.php';
require_once 'type/Default.class.php';
require_once 'inc/collectd.inc.php';

## LAYOUT
# apache[-X]/apache_bytes-X.rrd
# apache[-X]/apache_connections-X.rrd
# apache[-X]/apache_idle_workers-X.rrd
# apache[-X]/apache_requests-X.rrd
# apache[-X]/apache_scoreboard-X.rrd

$obj = new Type_Default($CONFIG);

switch ($obj->args['type']) {
	case 'apache_bytes':
		$obj->data_sources = array('count');
		$obj->ds_names = array(
			'count' => 'Bytes/s',
		);
		$obj->colors = array(
			'count' => '0000ff',
		);
		$obj->rrd_title = sprintf('Webserver Traffic%s',
			!isset($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : '');
		$obj->rrd_vertical = 'Bytes/s';
	break;
	case 'apache_connections':
		$obj->data_sources = array('count');
		$obj->ds_names = array(
			'count' => 'Conns/s',
		);
		$obj->colors = array(
			'count' => '00b000',
		);
		$obj->rrd_title = sprintf('Webserver Connections%s',
			!isset($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : '');
		$obj->rrd_vertical = 'Conns/s';
	break;
	case 'apache_idle_workers':
		$obj->data_sources = array('count');
		$obj->ds_names = array(
			'count' => 'Workers',
		);
		$obj->colors = array(
			'count' => '0000ff',
		);
		$obj->rrd_title = sprintf('Webserver Idle Workers%s',
			!isset($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : '');
		$obj->rrd_vertical = 'Workers';
	break;
	case 'apache_requests':
		$obj->data_sources = array('count');
		$obj->ds_names = array(
			'count' => 'Requests/s',
		);
		$obj->colors = array(
			'count' => '00b000',
		);
		$obj->rrd_title = sprintf('Webserver Requests%s',
			!isset($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : '');
		$obj->rrd_vertical = 'Requests/s';
	break;
	case 'apache_scoreboard':
		require_once 'type/GenericStacked.class.php';
		$obj = new Type_GenericStacked($CONFIG);
		$obj->data_sources = array('count');
		$obj->order = array('open', 'idle_cleanup', 'finishing', 'logging', 'closing', 'dnslookup', 'keepalive', 'sending', 'reading', 'starting', 'waiting');
		$obj->ds_names = array(
			'open'      => 'Open (empty)',
			'waiting'   => 'Waiting',
			'starting'  => 'Starting up',
			'reading'   => 'Reading request',
			'sending'   => 'Sending reply',
			'keepalive' => 'Keepalive',
			'dnslookup' => 'DNS Lookup',
			'closing'   => 'Closing',
			'logging'   => 'Logging',
			'finishing' => 'Finishing',
			'idle_cleanup' => 'Idle cleanup',
		);
		$obj->colors = array(
			'open'      => 'e0e0e0',
			'waiting'   => 'ffb000',
			'starting'  => 'ff00ff',
			'reading'   => '0000ff',
			'sending'   => '00e000',
			'keepalive' => '0080ff',
			'dnslookup' => 'ff0000',
			'closing'   => '000080',
			'logging'   => 'a000a0',
			'finishing' => '008080',
			'idle_cleanup' => 'ffff00',
		);
		$obj->rrd_title = sprintf('Webserver Scoreboard%s',
			!isset($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : '');
		$obj->rrd_vertical = 'Slots';
	break;
}

$obj->width = $width;
$obj->heigth = $heigth;
$obj->rrd_format = '%5.1lf';

collectd_flush($obj->identifiers);
$obj->rrd_graph();