diff options
Diffstat (limited to 'plugin/vserver.php')
-rw-r--r-- | plugin/vserver.php | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/plugin/vserver.php b/plugin/vserver.php new file mode 100644 index 0000000..57687e3 --- /dev/null +++ b/plugin/vserver.php | |||
@@ -0,0 +1,135 @@ | |||
1 | <?php | ||
2 | |||
3 | # Collectd VServer plugin | ||
4 | |||
5 | require_once 'conf/common.inc.php'; | ||
6 | require_once 'type/GenericIO.class.php'; | ||
7 | require_once 'type/GenericStacked.class.php'; | ||
8 | require_once 'inc/collectd.inc.php'; | ||
9 | |||
10 | # LAYOUT | ||
11 | # vserver-XXXX | ||
12 | # vserver-XXXX/if_octets-inet6.rrd | ||
13 | # vserver-XXXX/if_octets-inet.rrd | ||
14 | # vserver-XXXX/if_octets-other.rrd | ||
15 | # vserver-XXXX/if_octets-unix.rrd | ||
16 | # vserver-XXXX/if_octets-unspec.rrd | ||
17 | # vserver-XXXX/load.rrd | ||
18 | # vserver-XXXX/vs_memory-anon.rrd | ||
19 | # vserver-XXXX/vs_memory-rss.rrd | ||
20 | # vserver-XXXX/vs_memory-vml.rrd | ||
21 | # vserver-XXXX/vs_memory-vm.rrd | ||
22 | # vserver-XXXX/vs_processes.rrd | ||
23 | # vserver-XXXX/vs_threads-onhold.rrd | ||
24 | # vserver-XXXX/vs_threads-running.rrd | ||
25 | # vserver-XXXX/vs_threads-total.rrd | ||
26 | # vserver-XXXX/vs_threads-uninterruptable.rrd | ||
27 | |||
28 | $obj = new Type_Default($CONFIG); | ||
29 | |||
30 | switch($obj->args['type']) { | ||
31 | case 'load': | ||
32 | require_once "plugin/load.php"; | ||
33 | break; | ||
34 | case 'vs_memory': | ||
35 | $obj = new Type_GenericStacked($CONFIG); | ||
36 | $obj->order = array('vm', 'vml', 'rss', 'anon'); | ||
37 | # http://oldwiki.linux-vserver.org/Memory+Allocation | ||
38 | $obj->ds_names = array( | ||
39 | 'vm' => "Virtual memory pages", | ||
40 | 'vml' => "Pages locked into memory", | ||
41 | 'rss' => "Resident set size", | ||
42 | 'anon' => "Anonymous memory pages", | ||
43 | ); | ||
44 | $obj->colors = array( | ||
45 | 'vm' => '00e000', | ||
46 | 'vml' => '0000ff', | ||
47 | 'rss' => 'ffb000', | ||
48 | 'anon' => 'ff00ff', | ||
49 | ); | ||
50 | $obj->width = $width; | ||
51 | $obj->heigth = $heigth; | ||
52 | |||
53 | $obj->rrd_title = sprintf('Memory utilization on Vserver %s', $obj->args['pinstance']); | ||
54 | $obj->rrd_vertical = 'Bytes'; | ||
55 | $obj->rrd_format = '%5.1lf%s'; | ||
56 | |||
57 | collectd_flush($obj->identifiers); | ||
58 | $obj->rrd_graph(); | ||
59 | break; | ||
60 | case 'vs_threads': | ||
61 | $obj = new Type_GenericStacked($CONFIG); | ||
62 | $obj->order = array('running', 'uninterruptable', 'onhold', 'total'); | ||
63 | # http://linux-vserver.org/ProcFS | ||
64 | $obj->ds_names = array( | ||
65 | 'onhold' => "Number of threads on hold", | ||
66 | 'running' => "Number of running threads", | ||
67 | 'total' => "Total number of threads", | ||
68 | 'uninterruptable' => "Number of uninterruptible threads", | ||
69 | ); | ||
70 | $obj->colors = array( | ||
71 | 'onhold' => '00e000', | ||
72 | 'running' => '0000ff', | ||
73 | 'total' => 'ffb000', | ||
74 | 'uninterruptable' => 'ff00ff', | ||
75 | ); | ||
76 | $obj->width = $width; | ||
77 | $obj->heigth = $heigth; | ||
78 | |||
79 | $obj->rrd_title = sprintf('Threads on Vserver %s', $obj->args['pinstance']); | ||
80 | $obj->rrd_vertical = 'Numbers'; | ||
81 | $obj->rrd_format = '%5.1lf%s'; | ||
82 | |||
83 | collectd_flush($obj->identifiers); | ||
84 | $obj->rrd_graph(); | ||
85 | break; | ||
86 | case 'if_octets': | ||
87 | $obj->data_sources = array('rx', 'tx'); | ||
88 | $obj->ds_names = array( | ||
89 | 'inet-rx' => 'IPv4 Receive', | ||
90 | 'inet-tx' => 'IPv4 Transmit', | ||
91 | 'inet6-rx' => 'IPv6 Receive', | ||
92 | 'inet6-tx' => 'IPv6 Transmit', | ||
93 | ); | ||
94 | $obj->colors = array( | ||
95 | 'inet-rx' => '0000ff', | ||
96 | 'inet-tx' => '00b000', | ||
97 | 'inet6-rx' => 'e0e0e0', | ||
98 | 'inet6-tx' => 'ffb000', | ||
99 | 'other-rx' => 'ff00ff', | ||
100 | 'other-tx' => 'a000a0', | ||
101 | 'unix-rx' => '00e000', | ||
102 | 'unix-tx' => '0080ff', | ||
103 | 'unspec-rx' => 'ff0000', | ||
104 | 'unspec-tx' => '000080', | ||
105 | ); | ||
106 | $obj->rrd_title = sprintf('Traffic on Vserver %s', $obj->args['pinstance']); | ||
107 | $obj->rrd_vertical = 'Bytes per second'; | ||
108 | $obj->width = $width; | ||
109 | $obj->heigth = $heigth; | ||
110 | $obj->rrd_format = '%5.1lf%s'; | ||
111 | |||
112 | collectd_flush($obj->identifiers); | ||
113 | $obj->rrd_graph(); | ||
114 | break; | ||
115 | case 'vs_processes': | ||
116 | $obj->data_sources = array('value'); | ||
117 | $obj->ds_names = array( | ||
118 | 'value' => 'Processes', | ||
119 | ); | ||
120 | $obj->rrd_title = sprintf('Processes on Vserver %s', $obj->args['pinstance']); | ||
121 | $obj->rrd_vertical = 'Processes'; | ||
122 | |||
123 | $obj->width = $width; | ||
124 | $obj->heigth = $heigth; | ||
125 | $obj->rrd_format = '%5.1lf%s'; | ||
126 | |||
127 | collectd_flush($obj->identifiers); | ||
128 | $obj->rrd_graph(); | ||
129 | break; | ||
130 | |||
131 | default: | ||
132 | die('Not implemented yet.'); | ||
133 | break; | ||
134 | } | ||
135 | ?> | ||