diff options
author | Pim van den Berg | 2011-07-04 20:58:29 +0200 |
---|---|---|
committer | Pim van den Berg | 2011-07-04 20:58:29 +0200 |
commit | e7193cd45a03e438719b156f330c2c7061484b1b (patch) | |
tree | f740d4041e04055984919be6f9c269c479c23da2 | |
parent | type/Default: dont use t as ti when no ti is set (diff) | |
download | apt-panopticon_cgp-e7193cd45a03e438719b156f330c2c7061484b1b.zip apt-panopticon_cgp-e7193cd45a03e438719b156f330c2c7061484b1b.tar.gz apt-panopticon_cgp-e7193cd45a03e438719b156f330c2c7061484b1b.tar.bz2 apt-panopticon_cgp-e7193cd45a03e438719b156f330c2c7061484b1b.tar.xz |
plugin: add libvirt plugin
Diffstat (limited to '')
-rw-r--r-- | inc/collectd.inc.php | 2 | ||||
-rw-r--r-- | plugin/libvirt.php | 137 |
2 files changed, 138 insertions, 1 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index e5a7df4..51aedba 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php | |||
@@ -107,7 +107,7 @@ 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)$/', $item['p'])) | 110 | if ($CONFIG['version'] >= 5 || !preg_match('/^(df|interface|libvirt)$/', $item['p'])) |
111 | unset($item['ti']); | 111 | unset($item['ti']); |
112 | $data[] = $item; | 112 | $data[] = $item; |
113 | } | 113 | } |
diff --git a/plugin/libvirt.php b/plugin/libvirt.php new file mode 100644 index 0000000..0d5071a --- /dev/null +++ b/plugin/libvirt.php | |||
@@ -0,0 +1,137 @@ | |||
1 | <?php | ||
2 | |||
3 | # Collectd libvirt plugin | ||
4 | |||
5 | require_once 'conf/common.inc.php'; | ||
6 | require_once 'inc/collectd.inc.php'; | ||
7 | |||
8 | # LAYOUT | ||
9 | # libvirt/ | ||
10 | # libvirt/disk_octets-XXXX.rrd | ||
11 | # libvirt/disk_ops-XXXX.rrd | ||
12 | # libvirt/if_dropped-XXXX.rrd | ||
13 | # libvirt/if_errors-XXXX.rrd | ||
14 | # libvirt/if_octets-XXXX.rrd | ||
15 | # libvirt/if_packets-XXXX.rrd | ||
16 | # libvirt/virt_cpu_total.rrd | ||
17 | |||
18 | require_once 'type/GenericIO.class.php'; | ||
19 | $obj = new Type_GenericIO($CONFIG); | ||
20 | |||
21 | switch($obj->args['type']) { | ||
22 | case 'disk_octets': | ||
23 | $obj->data_sources = array('read', 'write'); | ||
24 | $obj->ds_names = array( | ||
25 | 'read' => 'Read', | ||
26 | 'write' => 'Written', | ||
27 | ); | ||
28 | $obj->colors = array( | ||
29 | 'read' => '0000ff', | ||
30 | 'write' => '00b000', | ||
31 | ); | ||
32 | $obj->rrd_title = sprintf('Disk Traffic (%s)', $obj->args['tinstance']); | ||
33 | $obj->rrd_vertical = 'Bytes per second'; | ||
34 | $obj->rrd_format = '%5.1lf%s'; | ||
35 | break; | ||
36 | case 'disk_ops': | ||
37 | $obj->data_sources = array('read', 'write'); | ||
38 | $obj->ds_names = array( | ||
39 | 'read' => 'Read', | ||
40 | 'write' => 'Written', | ||
41 | ); | ||
42 | $obj->colors = array( | ||
43 | 'read' => '0000ff', | ||
44 | 'write' => '00b000', | ||
45 | ); | ||
46 | $obj->rrd_title = sprintf('Disk Operations (%s)', $obj->args['tinstance']); | ||
47 | $obj->rrd_vertical = 'Ops per second'; | ||
48 | $obj->rrd_format = '%5.1lf%s'; | ||
49 | break; | ||
50 | case 'if_dropped': | ||
51 | $obj->data_sources = array('rx', 'tx'); | ||
52 | $obj->ds_names = array( | ||
53 | 'rx' => 'Receive', | ||
54 | 'tx' => 'Transmit', | ||
55 | ); | ||
56 | $obj->colors = array( | ||
57 | 'rx' => '0000ff', | ||
58 | 'tx' => '00b000', | ||
59 | ); | ||
60 | $obj->rrd_title = sprintf('Interface Packets Dropped (%s)', $obj->args['tinstance']); | ||
61 | $obj->rrd_vertical = 'Packets dropped per second'; | ||
62 | break; | ||
63 | case 'if_errors': | ||
64 | $obj->data_sources = array('rx', 'tx'); | ||
65 | $obj->ds_names = array( | ||
66 | 'rx' => 'Receive', | ||
67 | 'tx' => 'Transmit', | ||
68 | ); | ||
69 | $obj->colors = array( | ||
70 | 'rx' => '0000ff', | ||
71 | 'tx' => '00b000', | ||
72 | ); | ||
73 | $obj->rrd_title = sprintf('Interface Errors (%s)', $obj->args['tinstance']); | ||
74 | $obj->rrd_vertical = 'Errors per second'; | ||
75 | break; | ||
76 | case 'if_octets': | ||
77 | $obj->data_sources = array('rx', 'tx'); | ||
78 | $obj->ds_names = array( | ||
79 | 'rx' => 'Receive', | ||
80 | 'tx' => 'Transmit', | ||
81 | ); | ||
82 | $obj->colors = array( | ||
83 | 'rx' => '0000ff', | ||
84 | 'tx' => '00b000', | ||
85 | ); | ||
86 | $obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args['tinstance']); | ||
87 | $obj->rrd_vertical = 'Bytes per second'; | ||
88 | break; | ||
89 | case 'if_packets': | ||
90 | $obj->data_sources = array('rx', 'tx'); | ||
91 | $obj->ds_names = array( | ||
92 | 'rx' => 'Receive', | ||
93 | 'tx' => 'Transmit', | ||
94 | ); | ||
95 | $obj->colors = array( | ||
96 | 'rx' => '0000ff', | ||
97 | 'tx' => '00b000', | ||
98 | ); | ||
99 | $obj->rrd_title = sprintf('Interface Packets (%s)', $obj->args['tinstance']); | ||
100 | $obj->rrd_vertical = 'Packets per second'; | ||
101 | break; | ||
102 | case 'virt_cpu_total': | ||
103 | require_once 'type/Default.class.php'; | ||
104 | $obj = new Type_Default($CONFIG); | ||
105 | |||
106 | $obj->data_sources = array('ns'); | ||
107 | $obj->ds_names = array( | ||
108 | 'ns' => 'CPU time', | ||
109 | ); | ||
110 | $obj->colors = array( | ||
111 | 'ns' => '0000ff', | ||
112 | ); | ||
113 | $obj->rrd_title = 'CPU usage'; | ||
114 | $obj->rrd_vertical = 'CPU time'; | ||
115 | break; | ||
116 | case 'virt_vcpu': | ||
117 | require_once 'type/Default.class.php'; | ||
118 | $obj = new Type_Default($CONFIG); | ||
119 | |||
120 | $obj->data_sources = array('ns'); | ||
121 | $obj->ds_names = array( | ||
122 | 'ns' => 'VCPU time', | ||
123 | ); | ||
124 | $obj->colors = array( | ||
125 | 'ns' => '0000ff', | ||
126 | ); | ||
127 | $obj->rrd_title = 'VCPU usage'; | ||
128 | $obj->rrd_vertical = 'VCPU time'; | ||
129 | break; | ||
130 | } | ||
131 | |||
132 | $obj->width = $width; | ||
133 | $obj->heigth = $heigth; | ||
134 | $obj->rrd_format = '%5.1lf%s'; | ||
135 | |||
136 | collectd_flush($obj->identifiers); | ||
137 | $obj->rrd_graph(); | ||