aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/apache.php
blob: 73fe70e3b57b024cedf8e4c880f40114796d8643 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?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',
			!empty($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',
			!empty($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',
			!empty($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',
			!empty($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',

			'connect',
			'hard_error',
			'close',
			'response_end',
			'write',
			'response_start',
			'handle_request',
			'read_post',
			'request_end',
			'read',
			'request_start',
		);
		$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',

			'connect'        => 'Connect (empty)',
			'close'          => 'Close',
			'hard_error'     => 'Hard error',
			'read'           => 'Read',
			'read_post'      => 'Read POST',
			'write'          => 'Write',
			'handle_request' => 'Handle request',
			'request_start'  => 'Request start',
			'request_end'    => 'Request end',
			'response_start' => 'Response start',
			'response_end'   => 'Response end',
		);
		$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',

			'connect'        => 'e0e0e0',
			'close'          => '008080',
			'hard_error'     => 'ff0000',
			'read'           => 'ff00ff',
			'read_post'      => '00e000',
			'write'          => '000080',
			'handle_request' => '0080ff',
			'request_start'  => 'ffb000',
			'request_end'    => '0000ff',
			'response_start' => 'ffff00',
			'response_end'   => 'a000a0',
		);
		$obj->rrd_title = sprintf('Webserver Scoreboard%s',
			!empty($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();