aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/vserver.php
blob: 27e739fc44b99e559b3a60c99528387194f59b94 (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
<?php

# Collectd VServer plugin

require_once 'conf/common.inc.php';
require_once 'type/GenericIO.class.php';
require_once 'type/GenericStacked.class.php';

# LAYOUT
# vserver-XXXX
# vserver-XXXX/if_octets-inet6.rrd
# vserver-XXXX/if_octets-inet.rrd
# vserver-XXXX/if_octets-other.rrd
# vserver-XXXX/if_octets-unix.rrd
# vserver-XXXX/if_octets-unspec.rrd
# vserver-XXXX/load.rrd
# vserver-XXXX/vs_memory-anon.rrd
# vserver-XXXX/vs_memory-rss.rrd
# vserver-XXXX/vs_memory-vml.rrd
# vserver-XXXX/vs_memory-vm.rrd
# vserver-XXXX/vs_processes.rrd
# vserver-XXXX/vs_threads-onhold.rrd
# vserver-XXXX/vs_threads-running.rrd
# vserver-XXXX/vs_threads-total.rrd
# vserver-XXXX/vs_threads-uninterruptable.rrd

$obj = new Type_Default($CONFIG, $_GET);

switch($obj->args['type']) {
	case 'load':
		require_once "plugin/load.php";
		break;
	case 'vs_memory':
		$obj = new Type_GenericStacked($CONFIG, $_GET);
		$obj->order = array('vm', 'vml', 'rss', 'anon');
		# http://oldwiki.linux-vserver.org/Memory+Allocation
		$obj->ds_names = array(
			'vm' => "Virtual memory pages",
			'vml' => "Pages locked into memory",
			'rss' => "Resident set size",
			'anon' => "Anonymous memory pages",
		);
		$obj->colors = array(
			'vm' => '00e000',
			'vml' => '0000ff',
			'rss' => 'ffb000',
			'anon' => 'ff00ff',
			);

		$obj->rrd_title = sprintf('Memory utilization on Vserver %s', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Bytes';
		$obj->rrd_format = '%5.1lf%s';

		$obj->rrd_graph();
		break;
	case 'vs_threads':
		$obj = new Type_GenericStacked($CONFIG, $_GET);
		$obj->order = array('running', 'uninterruptable', 'onhold', 'total');
		# http://linux-vserver.org/ProcFS
		$obj->ds_names = array(
			'onhold' => "Number of threads on hold",
			'running' => "Number of running threads",
			'total' => "Total number of threads",
			'uninterruptable' => "Number of uninterruptible threads",
		);
		$obj->colors = array(
			'onhold' => '00e000',
			'running' => '0000ff',
			'total' => 'ffb000',
			'uninterruptable' => 'ff00ff',
			);

		$obj->rrd_title = sprintf('Threads on Vserver %s', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Numbers';
		$obj->rrd_format = '%5.1lf%s';

		$obj->rrd_graph();
		break;
	case 'if_octets':
		$obj->data_sources = array('rx', 'tx');
		$obj->ds_names = array(
			'inet-rx' => 'IPv4 Receive',
			'inet-tx' => 'IPv4 Transmit',
			'inet6-rx' => 'IPv6 Receive',
			'inet6-tx' => 'IPv6 Transmit',
			);
		$obj->colors = array(
			'inet-rx'   => '0000ff',
			'inet-tx'   => '00b000',
			'inet6-rx'  => 'e0e0e0',
			'inet6-tx'  => 'ffb000',
			'other-rx'  => 'ff00ff',
			'other-tx'  => 'a000a0',
			'unix-rx'   => '00e000',
			'unix-tx'   => '0080ff',
			'unspec-rx' => 'ff0000',
			'unspec-tx' => '000080',
			);
		$obj->rrd_title = sprintf('Traffic on Vserver %s', $obj->args['pinstance']);
			$obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['network_datasize']));
			$obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1;
		$obj->rrd_format = '%5.1lf%s';

		$obj->rrd_graph();
		break;
	case 'vs_processes':
		$obj->data_sources = array('value');
		$obj->ds_names = array(
			'value' => 'Processes',
		);
		$obj->rrd_title = sprintf('Processes on Vserver %s', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Processes';

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

		$obj->rrd_graph();
		break;

	default:
		die('Not implemented yet.');
		break;
}