From ff7368061b164a254308b9999caccd2bf704cddb Mon Sep 17 00:00:00 2001 From: Rex Tsai Date: Fri, 5 Nov 2010 19:18:28 +0800 Subject: plugin: add vserver plugin Signed-off-by: Pim van den Berg --- plugin/vserver.php | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 plugin/vserver.php (limited to 'plugin/vserver.php') 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 @@ +args['type']) { + case 'load': + require_once "plugin/load.php"; + break; + case 'vs_memory': + $obj = new Type_GenericStacked($CONFIG); + $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->width = $width; + $obj->heigth = $heigth; + + $obj->rrd_title = sprintf('Memory utilization on Vserver %s', $obj->args['pinstance']); + $obj->rrd_vertical = 'Bytes'; + $obj->rrd_format = '%5.1lf%s'; + + collectd_flush($obj->identifiers); + $obj->rrd_graph(); + break; + case 'vs_threads': + $obj = new Type_GenericStacked($CONFIG); + $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->width = $width; + $obj->heigth = $heigth; + + $obj->rrd_title = sprintf('Threads on Vserver %s', $obj->args['pinstance']); + $obj->rrd_vertical = 'Numbers'; + $obj->rrd_format = '%5.1lf%s'; + + collectd_flush($obj->identifiers); + $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 = 'Bytes per second'; + $obj->width = $width; + $obj->heigth = $heigth; + $obj->rrd_format = '%5.1lf%s'; + + collectd_flush($obj->identifiers); + $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->width = $width; + $obj->heigth = $heigth; + $obj->rrd_format = '%5.1lf%s'; + + collectd_flush($obj->identifiers); + $obj->rrd_graph(); + break; + + default: + die('Not implemented yet.'); + break; +} +?> -- cgit v1.1