diff options
| author | Pim van den Berg | 2011-07-04 21:07:22 +0200 |
|---|---|---|
| committer | Pim van den Berg | 2011-07-04 21:12:48 +0200 |
| commit | f0db176e8c1e90bcce8da408648917d3e8243386 (patch) | |
| tree | 8febb0056edf4e4975e8c45e61d85d2150de21b9 | |
| parent | plugin: add libvirt plugin (diff) | |
| download | apt-panopticon_cgp-f0db176e8c1e90bcce8da408648917d3e8243386.zip apt-panopticon_cgp-f0db176e8c1e90bcce8da408648917d3e8243386.tar.gz apt-panopticon_cgp-f0db176e8c1e90bcce8da408648917d3e8243386.tar.bz2 apt-panopticon_cgp-f0db176e8c1e90bcce8da408648917d3e8243386.tar.xz | |
plugin/libvirt: collectd 5 compatibility
| -rw-r--r-- | inc/collectd.inc.php | 5 | ||||
| -rw-r--r-- | plugin/libvirt.php | 22 |
2 files changed, 19 insertions, 8 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index 51aedba..11dc91f 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php | |||
| @@ -107,8 +107,9 @@ function group_plugindata($plugindata) { | |||
| 107 | # type instances should be grouped in 1 graph | 107 | # type instances should be grouped in 1 graph |
| 108 | foreach ($plugindata as $item) { | 108 | foreach ($plugindata as $item) { |
| 109 | # backwards compatibility | 109 | # backwards compatibility |
| 110 | if ($CONFIG['version'] >= 5 || !preg_match('/^(df|interface|libvirt)$/', $item['p'])) | 110 | if ($CONFIG['version'] >= 5 || !preg_match('/^(df|interface)$/', $item['p'])) |
| 111 | unset($item['ti']); | 111 | if($item['p'] != 'libvirt') |
| 112 | unset($item['ti']); | ||
| 112 | $data[] = $item; | 113 | $data[] = $item; |
| 113 | } | 114 | } |
| 114 | 115 | ||
diff --git a/plugin/libvirt.php b/plugin/libvirt.php index 0d5071a..829c592 100644 --- a/plugin/libvirt.php +++ b/plugin/libvirt.php | |||
| @@ -103,12 +103,12 @@ switch($obj->args['type']) { | |||
| 103 | require_once 'type/Default.class.php'; | 103 | require_once 'type/Default.class.php'; |
| 104 | $obj = new Type_Default($CONFIG); | 104 | $obj = new Type_Default($CONFIG); |
| 105 | 105 | ||
| 106 | $obj->data_sources = array('ns'); | 106 | $obj->data_sources = array('value'); |
| 107 | $obj->ds_names = array( | 107 | $obj->ds_names = array( |
| 108 | 'ns' => 'CPU time', | 108 | 'value' => 'CPU time', |
| 109 | ); | 109 | ); |
| 110 | $obj->colors = array( | 110 | $obj->colors = array( |
| 111 | 'ns' => '0000ff', | 111 | 'value' => '0000ff', |
| 112 | ); | 112 | ); |
| 113 | $obj->rrd_title = 'CPU usage'; | 113 | $obj->rrd_title = 'CPU usage'; |
| 114 | $obj->rrd_vertical = 'CPU time'; | 114 | $obj->rrd_vertical = 'CPU time'; |
| @@ -117,12 +117,12 @@ switch($obj->args['type']) { | |||
| 117 | require_once 'type/Default.class.php'; | 117 | require_once 'type/Default.class.php'; |
| 118 | $obj = new Type_Default($CONFIG); | 118 | $obj = new Type_Default($CONFIG); |
| 119 | 119 | ||
| 120 | $obj->data_sources = array('ns'); | 120 | $obj->data_sources = array('value'); |
| 121 | $obj->ds_names = array( | 121 | $obj->ds_names = array( |
| 122 | 'ns' => 'VCPU time', | 122 | 'value' => 'VCPU time', |
| 123 | ); | 123 | ); |
| 124 | $obj->colors = array( | 124 | $obj->colors = array( |
| 125 | 'ns' => '0000ff', | 125 | 'value' => '0000ff', |
| 126 | ); | 126 | ); |
| 127 | $obj->rrd_title = 'VCPU usage'; | 127 | $obj->rrd_title = 'VCPU usage'; |
| 128 | $obj->rrd_vertical = 'VCPU time'; | 128 | $obj->rrd_vertical = 'VCPU time'; |
| @@ -133,5 +133,15 @@ $obj->width = $width; | |||
| 133 | $obj->heigth = $heigth; | 133 | $obj->heigth = $heigth; |
| 134 | $obj->rrd_format = '%5.1lf%s'; | 134 | $obj->rrd_format = '%5.1lf%s'; |
| 135 | 135 | ||
| 136 | if ($CONFIG['version'] < 5 && count($obj->data_sources) == 1) { | ||
| 137 | $obj->data_sources = array('ns'); | ||
| 138 | |||
| 139 | $obj->ds_names['ns'] = $obj->ds_names['value']; | ||
| 140 | unset($obj->ds_names['value']); | ||
| 141 | |||
| 142 | $obj->colors['ns'] = $obj->colors['value']; | ||
| 143 | unset($obj->colors['value']); | ||
| 144 | } | ||
| 145 | |||
| 136 | collectd_flush($obj->identifiers); | 146 | collectd_flush($obj->identifiers); |
| 137 | $obj->rrd_graph(); | 147 | $obj->rrd_graph(); |
