aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/nginx.php
blob: b05cd670fecaf5d9cdcd8a816d3f02ebb3e7669d (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
<?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/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 '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->width = $width;
$obj->heigth = $heigth;
$obj->rrd_format = '%5.1lf%s';

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