aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/nginx.php
blob: 9d51a8e6c295ef9bc3727728f49edde952611d4a (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
<?php

# Collectd nginx plugin

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

## LAYOUT
# nginx/
# nginx/connections-accepted.rrd
# nginx/connections-handled.rrd
# nginx/nginx_connections-active.rrd
# nginx/nginx_connections-reading.rrd
# nginx/nginx_connections-waiting.rrd
# nginx/nginx_connections-writing.rrd
# nginx/nginx_requests.rrd

$obj = new Type_Default($CONFIG);

switch($obj->args['type'])
{
	case 'connections':
		$obj->order = array('accepted', 'handled');
		$obj->ds_names = array(
			'accepted'  => 'Accepted',
			'handled' => 'Handled',
		);
		$obj->colors = array(
			'accepted' => 'ff0000',
			'handled' => '0000ff',
		);
		$obj->rrd_title = sprintf('nginx connections');
		$obj->rrd_vertical = 'Connections/s';
	break;
	case 'nginx_connections':
		$obj->order = array('active', 'reading', 'waiting', 'writing');
		$obj->ds_names = array(
			'active'  => 'Active',
			'reading' => 'Reading',
			'waiting' => 'Waiting',
			'writing' => 'Writing',
		);
		$obj->colors = array(
			'active'  => '005d57',
			'reading' => '4444ff',
			'waiting' => 'f24ac8',
			'writing' => '00cf00',
		);
		$obj->rrd_title = sprintf('nginx connections');
		$obj->rrd_vertical = 'Connections/s';
	break;
	case 'nginx_requests':
		$obj->ds_names = array(
			'value' => 'Requests',
		);
		$obj->colors = array(
			'value' => '00aa00',
		);
		$obj->rrd_title = sprintf('nginx requests');
		$obj->rrd_vertical = 'Requests per second';
	break;
}

$obj->rrd_format = '%5.1lf%s';

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