aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPim van den Berg2014-05-03 11:40:46 +0200
committerPim van den Berg2014-05-03 19:19:05 +0200
commit1bb10c398d1a3198a8b86517bd780b8122e2e69d (patch)
tree669ea50b9b0efe268f4bb9153459f95ccfb167b5
parenttype: move generic functions to base class (diff)
downloadapt-panopticon_cgp-1bb10c398d1a3198a8b86517bd780b8122e2e69d.zip
apt-panopticon_cgp-1bb10c398d1a3198a8b86517bd780b8122e2e69d.tar.gz
apt-panopticon_cgp-1bb10c398d1a3198a8b86517bd780b8122e2e69d.tar.bz2
apt-panopticon_cgp-1bb10c398d1a3198a8b86517bd780b8122e2e69d.tar.xz
move collectd_flush function to base class
-rw-r--r--inc/collectd.inc.php65
-rw-r--r--inc/html.inc.php6
-rw-r--r--plugin/aggregation.php2
-rw-r--r--plugin/apache.php2
-rw-r--r--plugin/apcups.php2
-rw-r--r--plugin/battery.php2
-rw-r--r--plugin/bind.php2
-rw-r--r--plugin/conntrack.php2
-rw-r--r--plugin/contextswitch.php2
-rw-r--r--plugin/cpu.php2
-rw-r--r--plugin/cpufreq.php2
-rw-r--r--plugin/dbi.php2
-rw-r--r--plugin/df.php2
-rw-r--r--plugin/disk.php2
-rw-r--r--plugin/dns.php2
-rw-r--r--plugin/entropy.php2
-rw-r--r--plugin/filecount.php2
-rw-r--r--plugin/hddtemp.php2
-rw-r--r--plugin/interface.php2
-rw-r--r--plugin/ip6tables.php2
-rw-r--r--plugin/ipmi.php2
-rw-r--r--plugin/iptables.php2
-rw-r--r--plugin/irq.php2
-rw-r--r--plugin/libvirt.php2
-rw-r--r--plugin/load.php2
-rw-r--r--plugin/md.php2
-rw-r--r--plugin/memcached.php2
-rw-r--r--plugin/memory.php2
-rw-r--r--plugin/mysql.php2
-rw-r--r--plugin/netlink.php2
-rw-r--r--plugin/nfs.php2
-rw-r--r--plugin/nginx.php2
-rw-r--r--plugin/ntpd.php2
-rw-r--r--plugin/nut.php2
-rw-r--r--plugin/openvpn.php2
-rw-r--r--plugin/ping.php2
-rw-r--r--plugin/postgresql.php2
-rw-r--r--plugin/powerdns.php2
-rw-r--r--plugin/processes.php2
-rw-r--r--plugin/sensors.php2
-rw-r--r--plugin/snmp.php2
-rw-r--r--plugin/swap.php2
-rw-r--r--plugin/tail.php2
-rw-r--r--plugin/tcpconns.php2
-rw-r--r--plugin/thermal.php2
-rw-r--r--plugin/uptime.php2
-rw-r--r--plugin/users.php2
-rw-r--r--plugin/varnish.php2
-rw-r--r--plugin/vmem.php2
-rw-r--r--plugin/vserver.php5
-rw-r--r--plugin/wireless.php2
-rw-r--r--plugin/zfs_arc.php2
-rw-r--r--type/Base.class.php70
53 files changed, 75 insertions, 169 deletions
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php
index 74595aa..3bfc6ff 100644
--- a/inc/collectd.inc.php
+++ b/inc/collectd.inc.php
@@ -167,68 +167,3 @@ function plugin_sort($data) {
167 167
168 return $data; 168 return $data;
169} 169}
170
171function socket_cmd($socket, $cmd) {
172 $r = fwrite($socket, $cmd, strlen($cmd));
173 if ($r === false || $r != strlen($cmd)) {
174 error_log(sprintf('ERROR: Failed to write full command to unix-socket: %d out of %d written',
175 $r === false ? -1 : $r, strlen($cmd)));
176 return FALSE;
177 }
178
179 $resp = fgets($socket,128);
180 if ($resp === false) {
181 error_log(sprintf('ERROR: Failed to read response from collectd for command: %s',
182 trim($cmd)));
183 return FALSE;
184 }
185
186 $n = (int)$resp;
187 while ($n-- > 0)
188 fgets($socket,128);
189
190 return TRUE;
191}
192
193# tell collectd to FLUSH all data of the identifier(s)
194function collectd_flush($identifier) {
195 global $CONFIG;
196
197 if (!$CONFIG['socket'])
198 return FALSE;
199
200 if (!$identifier || (is_array($identifier) && count($identifier) == 0) ||
201 !(is_string($identifier) || is_array($identifier)))
202 return FALSE;
203
204 if (!is_array($identifier))
205 $identifier = array($identifier);
206
207 $u_errno = 0;
208 $u_errmsg = '';
209 if (! $socket = @fsockopen($CONFIG['socket'], 0, $u_errno, $u_errmsg)) {
210 error_log(sprintf('ERROR: Failed to open unix-socket to %s (%d: %s)',
211 $CONFIG['socket'], $u_errno, $u_errmsg));
212 return FALSE;
213 }
214
215 if ($CONFIG['flush_type'] == 'collectd'){
216 $cmd = 'FLUSH';
217 foreach ($identifier as $val)
218 $cmd .= sprintf(' identifier="%s"', $val);
219 $cmd .= "\n";
220 socket_cmd($socket, $cmd);
221 }
222 elseif ($CONFIG['flush_type'] == 'rrdcached') {
223 foreach ($identifier as $val) {
224 $cmd = sprintf("FLUSH %s.rrd\n", $val);
225 socket_cmd($socket, $cmd);
226 }
227 }
228
229 fclose($socket);
230
231 return TRUE;
232}
233
234?>
diff --git a/inc/html.inc.php b/inc/html.inc.php
index 2bcbc3f..7f6e7c0 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -196,7 +196,11 @@ function host_summary($cat, $hosts) {
196 $CONFIG['weburl'],$host, $host); 196 $CONFIG['weburl'],$host, $host);
197 197
198 if ($CONFIG['showload']) { 198 if ($CONFIG['showload']) {
199 collectd_flush(sprintf('%s/load/load', $host)); 199 require_once 'type/Default.class.php';
200 $load = array('h' => $host, 'p' => 'load', 't' => 'load');
201 $obj = new Type_Default($CONFIG, $load);
202 $obj->collectd_flush();
203
200 $rrd_info = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/load/load.rrd'); 204 $rrd_info = $rrd->rrd_info($CONFIG['datadir'].'/'.$host.'/load/load.rrd');
201 205
202 # ignore if file does not exist 206 # ignore if file does not exist
diff --git a/plugin/aggregation.php b/plugin/aggregation.php
index c4353ce..2a74403 100644
--- a/plugin/aggregation.php
+++ b/plugin/aggregation.php
@@ -3,7 +3,6 @@
3# Collectd aggregation plugin 3# Collectd aggregation plugin
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'inc/collectd.inc.php';
7 6
8## LAYOUT 7## LAYOUT
9# aggregation-(plugin)-(calculate)/(type)-(type-instance).rrd 8# aggregation-(plugin)-(calculate)/(type)-(type-instance).rrd
@@ -42,7 +41,6 @@ switch($pi[0]) {
42 $obj->rrd_format = '%7.2lf'; 41 $obj->rrd_format = '%7.2lf';
43 $obj->rrdtool_opts .= ' -u 100'; 42 $obj->rrdtool_opts .= ' -u 100';
44 43
45 collectd_flush($obj->identifiers);
46 $obj->rrd_graph(); 44 $obj->rrd_graph();
47 break; 45 break;
48} 46}
diff --git a/plugin/apache.php b/plugin/apache.php
index 226385e..df7fe49 100644
--- a/plugin/apache.php
+++ b/plugin/apache.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# apache[-X]/apache_bytes-X.rrd 9# apache[-X]/apache_bytes-X.rrd
@@ -165,5 +164,4 @@ if ($CONFIG['version'] < 5) {
165 } 164 }
166} 165}
167 166
168collectd_flush($obj->identifiers);
169$obj->rrd_graph(); 167$obj->rrd_graph();
diff --git a/plugin/apcups.php b/plugin/apcups.php
index 24d1918..626b8f4 100644
--- a/plugin/apcups.php
+++ b/plugin/apcups.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# apcups/ 9# apcups/
@@ -86,6 +85,5 @@ if ($CONFIG['version'] < 5 &&
86 unset($obj->colors['value']); 85 unset($obj->colors['value']);
87} 86}
88 87
89collectd_flush($obj->identifiers);
90$obj->rrd_graph(); 88$obj->rrd_graph();
91 89
diff --git a/plugin/battery.php b/plugin/battery.php
index 740d5cb..631776b 100644
--- a/plugin/battery.php
+++ b/plugin/battery.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# battery-X/ 9# battery-X/
@@ -35,6 +34,5 @@ switch($obj->args['type']) {
35} 34}
36$obj->rrd_format = '%4.1lf'; 35$obj->rrd_format = '%4.1lf';
37 36
38collectd_flush($obj->identifiers);
39$obj->rrd_graph(); 37$obj->rrd_graph();
40 38
diff --git a/plugin/bind.php b/plugin/bind.php
index 702fec5..cfbd4c6 100644
--- a/plugin/bind.php
+++ b/plugin/bind.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9 8
10$obj = new Type_GenericStacked($CONFIG, $_GET); 9$obj = new Type_GenericStacked($CONFIG, $_GET);
@@ -12,5 +11,4 @@ $obj = new Type_GenericStacked($CONFIG, $_GET);
12$obj->rrd_title = sprintf('%s/%s', $obj->args['pinstance'], $obj->args['type']); 11$obj->rrd_title = sprintf('%s/%s', $obj->args['pinstance'], $obj->args['type']);
13$obj->rrd_format = '%5.1lf%s'; 12$obj->rrd_format = '%5.1lf%s';
14 13
15collectd_flush($obj->identifiers);
16$obj->rrd_graph(); 14$obj->rrd_graph();
diff --git a/plugin/conntrack.php b/plugin/conntrack.php
index 27a3656..6e2bba0 100644
--- a/plugin/conntrack.php
+++ b/plugin/conntrack.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# conntrack/conntrack.rrd 9# conntrack/conntrack.rrd
@@ -33,5 +32,4 @@ if ($CONFIG['version'] < 5) {
33 unset($obj->colors['value']); 32 unset($obj->colors['value']);
34} 33}
35 34
36collectd_flush($obj->identifiers);
37$obj->rrd_graph(); 35$obj->rrd_graph();
diff --git a/plugin/contextswitch.php b/plugin/contextswitch.php
index e71c417..71f6d9d 100644
--- a/plugin/contextswitch.php
+++ b/plugin/contextswitch.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# contextswitch/contextswitch.rrd 9# contextswitch/contextswitch.rrd
@@ -32,5 +31,4 @@ if ($CONFIG['version'] < 5) {
32 unset($obj->colors['value']); 31 unset($obj->colors['value']);
33} 32}
34 33
35collectd_flush($obj->identifiers);
36$obj->rrd_graph(); 34$obj->rrd_graph();
diff --git a/plugin/cpu.php b/plugin/cpu.php
index a3e968a..76914a7 100644
--- a/plugin/cpu.php
+++ b/plugin/cpu.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# cpu-X/ 9# cpu-X/
@@ -46,5 +45,4 @@ $obj->rrd_vertical = 'Jiffies';
46$obj->rrd_format = '%5.2lf'; 45$obj->rrd_format = '%5.2lf';
47$obj->rrdtool_opts .= ' -u 100'; 46$obj->rrdtool_opts .= ' -u 100';
48 47
49collectd_flush($obj->identifiers);
50$obj->rrd_graph(); 48$obj->rrd_graph();
diff --git a/plugin/cpufreq.php b/plugin/cpufreq.php
index fbdc6ff..d9542d1 100644
--- a/plugin/cpufreq.php
+++ b/plugin/cpufreq.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# cpufreq/cpufreq-X.rrd 9# cpufreq/cpufreq-X.rrd
@@ -15,5 +14,4 @@ $obj->rrd_title = 'CPU frequency scaling';
15$obj->rrd_vertical = 'Hz'; 14$obj->rrd_vertical = 'Hz';
16$obj->rrd_format = '%5.1lf%s'; 15$obj->rrd_format = '%5.1lf%s';
17 16
18collectd_flush($obj->identifiers);
19$obj->rrd_graph(); 17$obj->rrd_graph();
diff --git a/plugin/dbi.php b/plugin/dbi.php
index 31aacc9..b9dd268 100644
--- a/plugin/dbi.php
+++ b/plugin/dbi.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9 8
10 9
@@ -14,5 +13,4 @@ $obj = new Type_Default($CONFIG, $_GET);
14$obj->rrd_title = sprintf('%s', $obj->args['pinstance'], $obj->args['type']); 13$obj->rrd_title = sprintf('%s', $obj->args['pinstance'], $obj->args['type']);
15$obj->rrd_format = '%5.1lf%s'; 14$obj->rrd_format = '%5.1lf%s';
16 15
17collectd_flush($obj->identifiers);
18$obj->rrd_graph(); 16$obj->rrd_graph();
diff --git a/plugin/df.php b/plugin/df.php
index 464e26c..f6d861b 100644
--- a/plugin/df.php
+++ b/plugin/df.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9# LAYOUT 8# LAYOUT
10# 9#
@@ -46,5 +45,4 @@ if ($CONFIG['version'] < 5) {
46 $obj->rrd_title = sprintf('Free space (%s)', $obj->args['tinstance']); 45 $obj->rrd_title = sprintf('Free space (%s)', $obj->args['tinstance']);
47} 46}
48 47
49collectd_flush($obj->identifiers);
50$obj->rrd_graph(); 48$obj->rrd_graph();
diff --git a/plugin/disk.php b/plugin/disk.php
index 33bb147..27a4acd 100644
--- a/plugin/disk.php
+++ b/plugin/disk.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericIO.class.php'; 6require_once 'type/GenericIO.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# disk-XXXX/ 9# disk-XXXX/
@@ -47,5 +46,4 @@ switch($obj->args['type']) {
47 break; 46 break;
48} 47}
49 48
50collectd_flush($obj->identifiers);
51$obj->rrd_graph(); 49$obj->rrd_graph();
diff --git a/plugin/dns.php b/plugin/dns.php
index f770988..cb9bb02 100644
--- a/plugin/dns.php
+++ b/plugin/dns.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# dns/ 9# dns/
@@ -49,5 +48,4 @@ switch($obj->args['type']) {
49 break; 48 break;
50} 49}
51 50
52collectd_flush($obj->identifiers);
53$obj->rrd_graph(); 51$obj->rrd_graph();
diff --git a/plugin/entropy.php b/plugin/entropy.php
index 137e5a2..0433a4f 100644
--- a/plugin/entropy.php
+++ b/plugin/entropy.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# entropy/entropy.rrd 9# entropy/entropy.rrd
@@ -32,5 +31,4 @@ if ($CONFIG['version'] < 5) {
32 unset($obj->colors['value']); 31 unset($obj->colors['value']);
33} 32}
34 33
35collectd_flush($obj->identifiers);
36$obj->rrd_graph(); 34$obj->rrd_graph();
diff --git a/plugin/filecount.php b/plugin/filecount.php
index 812be9c..5fa524d 100644
--- a/plugin/filecount.php
+++ b/plugin/filecount.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# filecount-X/ 9# filecount-X/
@@ -31,5 +30,4 @@ switch($obj->args['type']) {
31 break; 30 break;
32} 31}
33 32
34collectd_flush($obj->identifiers);
35$obj->rrd_graph(); 33$obj->rrd_graph();
diff --git a/plugin/hddtemp.php b/plugin/hddtemp.php
index 5526154..1d366a9 100644
--- a/plugin/hddtemp.php
+++ b/plugin/hddtemp.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# hddtemp/temperature-<disk>.rrd 9# hddtemp/temperature-<disk>.rrd
@@ -15,5 +14,4 @@ $obj->rrd_title = 'HDD Temperature';
15$obj->rrd_vertical = '°C'; 14$obj->rrd_vertical = '°C';
16$obj->rrd_format = '%.1lf'; 15$obj->rrd_format = '%.1lf';
17 16
18collectd_flush($obj->identifiers);
19$obj->rrd_graph(); 17$obj->rrd_graph();
diff --git a/plugin/interface.php b/plugin/interface.php
index c51d732..cc8c5ce 100644
--- a/plugin/interface.php
+++ b/plugin/interface.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericIO.class.php'; 6require_once 'type/GenericIO.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9# LAYOUT - Collectd 4 8# LAYOUT - Collectd 4
10# interface/ 9# interface/
@@ -46,5 +45,4 @@ switch($obj->args['type']) {
46 break; 45 break;
47} 46}
48 47
49collectd_flush($obj->identifiers);
50$obj->rrd_graph(); 48$obj->rrd_graph();
diff --git a/plugin/ip6tables.php b/plugin/ip6tables.php
index cd95bc8..090c475 100644
--- a/plugin/ip6tables.php
+++ b/plugin/ip6tables.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# ip6tables/ipt_bytes-XXX.rrd 9# ip6tables/ipt_bytes-XXX.rrd
@@ -24,5 +23,4 @@ switch($_GET['t']) {
24$obj->rrd_vertical = ''; 23$obj->rrd_vertical = '';
25$obj->rrd_format = '%5.1lf%s'; 24$obj->rrd_format = '%5.1lf%s';
26 25
27collectd_flush($obj->identifiers);
28$obj->rrd_graph(); 26$obj->rrd_graph();
diff --git a/plugin/ipmi.php b/plugin/ipmi.php
index 9f975b5..8e6b7bf 100644
--- a/plugin/ipmi.php
+++ b/plugin/ipmi.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT (similar to sensors plugin) 8## LAYOUT (similar to sensors plugin)
10# 9#
@@ -41,5 +40,4 @@ switch($obj->args['type']) {
41 break; 40 break;
42} 41}
43 42
44collectd_flush($obj->identifiers);
45$obj->rrd_graph(); 43$obj->rrd_graph();
diff --git a/plugin/iptables.php b/plugin/iptables.php
index de060be..e60d2dc 100644
--- a/plugin/iptables.php
+++ b/plugin/iptables.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# iptables/ipt_bytes-XXX.rrd 9# iptables/ipt_bytes-XXX.rrd
@@ -24,5 +23,4 @@ switch($_GET['t']) {
24$obj->rrd_vertical = ''; 23$obj->rrd_vertical = '';
25$obj->rrd_format = '%5.1lf%s'; 24$obj->rrd_format = '%5.1lf%s';
26 25
27collectd_flush($obj->identifiers);
28$obj->rrd_graph(); 26$obj->rrd_graph();
diff --git a/plugin/irq.php b/plugin/irq.php
index 52d49e8..6cd87f9 100644
--- a/plugin/irq.php
+++ b/plugin/irq.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# irq/ 9# irq/
@@ -16,5 +15,4 @@ $obj->rrd_title = 'Interrupts';
16$obj->rrd_vertical = 'IRQs/s'; 15$obj->rrd_vertical = 'IRQs/s';
17$obj->rrd_format = '%6.1lf'; 16$obj->rrd_format = '%6.1lf';
18 17
19collectd_flush($obj->identifiers);
20$obj->rrd_graph(); 18$obj->rrd_graph();
diff --git a/plugin/libvirt.php b/plugin/libvirt.php
index 08d0a6d..0d7fff0 100644
--- a/plugin/libvirt.php
+++ b/plugin/libvirt.php
@@ -3,7 +3,6 @@
3# Collectd libvirt plugin 3# Collectd libvirt plugin
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'inc/collectd.inc.php';
7 6
8# LAYOUT 7# LAYOUT
9# libvirt/ 8# libvirt/
@@ -142,5 +141,4 @@ if ($CONFIG['version'] < 5 && count($obj->data_sources) == 1) {
142 unset($obj->colors['value']); 141 unset($obj->colors['value']);
143} 142}
144 143
145collectd_flush($obj->identifiers);
146$obj->rrd_graph(); 144$obj->rrd_graph();
diff --git a/plugin/load.php b/plugin/load.php
index 0429735..a6e3355 100644
--- a/plugin/load.php
+++ b/plugin/load.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# load/load.rrd 9# load/load.rrd
@@ -25,5 +24,4 @@ $obj->rrd_title = 'System load';
25$obj->rrd_vertical = 'System load'; 24$obj->rrd_vertical = 'System load';
26$obj->rrd_format = '%.2lf'; 25$obj->rrd_format = '%.2lf';
27 26
28collectd_flush($obj->identifiers);
29$obj->rrd_graph(); 27$obj->rrd_graph();
diff --git a/plugin/md.php b/plugin/md.php
index c435a23..03f529a 100644
--- a/plugin/md.php
+++ b/plugin/md.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# md-XXXX/ 9# md-XXXX/
@@ -18,5 +17,4 @@ $obj->rrd_title = sprintf('Disks (md-%s)', $obj->args['pinstance']);
18$obj->rrd_vertical = '#'; 17$obj->rrd_vertical = '#';
19$obj->rrd_format = '%2.0lf'; 18$obj->rrd_format = '%2.0lf';
20 19
21collectd_flush($obj->identifiers);
22$obj->rrd_graph(); 20$obj->rrd_graph();
diff --git a/plugin/memcached.php b/plugin/memcached.php
index 3424769..09715ae 100644
--- a/plugin/memcached.php
+++ b/plugin/memcached.php
@@ -7,7 +7,6 @@
7 7
8 8
9require_once 'conf/common.inc.php'; 9require_once 'conf/common.inc.php';
10require_once 'inc/collectd.inc.php';
11 10
12## LAYOUT 11## LAYOUT
13# df-cache.rrd 12# df-cache.rrd
@@ -177,5 +176,4 @@ switch(GET('t')) {
177 176
178$obj->rrd_format = '%5.1lf%s'; 177$obj->rrd_format = '%5.1lf%s';
179 178
180collectd_flush($obj->identifiers);
181$obj->rrd_graph(); 179$obj->rrd_graph();
diff --git a/plugin/memory.php b/plugin/memory.php
index 20fb200..9fd2e30 100644
--- a/plugin/memory.php
+++ b/plugin/memory.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# memory/ 9# memory/
@@ -42,5 +41,4 @@ $obj->rrd_title = 'Physical memory utilization';
42$obj->rrd_vertical = 'Bytes'; 41$obj->rrd_vertical = 'Bytes';
43$obj->rrd_format = '%5.1lf%s'; 42$obj->rrd_format = '%5.1lf%s';
44 43
45collectd_flush($obj->identifiers);
46$obj->rrd_graph(); 44$obj->rrd_graph();
diff --git a/plugin/mysql.php b/plugin/mysql.php
index 445176b..aad0131 100644
--- a/plugin/mysql.php
+++ b/plugin/mysql.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9$obj = new Type_GenericStacked($CONFIG, $_GET); 8$obj = new Type_GenericStacked($CONFIG, $_GET);
10$obj->rrd_format = '%5.1lf%s'; 9$obj->rrd_format = '%5.1lf%s';
@@ -138,5 +137,4 @@ switch($obj->args['type'])
138 break; 137 break;
139} 138}
140 139
141collectd_flush($obj->identifiers);
142$obj->rrd_graph(); 140$obj->rrd_graph();
diff --git a/plugin/netlink.php b/plugin/netlink.php
index 2dfbab6..28a25f1 100644
--- a/plugin/netlink.php
+++ b/plugin/netlink.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9$obj = new Type_GenericStacked($CONFIG, $_GET); 8$obj = new Type_GenericStacked($CONFIG, $_GET);
10 9
@@ -120,5 +119,4 @@ switch($obj->args['type']) {
120 break; 119 break;
121} 120}
122 121
123collectd_flush($obj->identifiers);
124$obj->rrd_graph(); 122$obj->rrd_graph();
diff --git a/plugin/nfs.php b/plugin/nfs.php
index efcfd1e..612580c 100644
--- a/plugin/nfs.php
+++ b/plugin/nfs.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9 8
10# Check http://github.com/octo/collectd/blob/master/src/nfs.c 9# Check http://github.com/octo/collectd/blob/master/src/nfs.c
@@ -29,5 +28,4 @@ $obj->rrd_title = sprintf('NFS-%s Procedures', $obj->args['pinstance']);
29$obj->rrd_vertical = 'Procedures'; 28$obj->rrd_vertical = 'Procedures';
30$obj->rrd_format = '%5.2lf'; 29$obj->rrd_format = '%5.2lf';
31 30
32collectd_flush($obj->identifiers);
33$obj->rrd_graph(); 31$obj->rrd_graph();
diff --git a/plugin/nginx.php b/plugin/nginx.php
index d55a886..7d70190 100644
--- a/plugin/nginx.php
+++ b/plugin/nginx.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# nginx/ 9# nginx/
@@ -64,5 +63,4 @@ switch($obj->args['type'])
64 63
65$obj->rrd_format = '%5.1lf%s'; 64$obj->rrd_format = '%5.1lf%s';
66 65
67collectd_flush($obj->identifiers);
68$obj->rrd_graph(); 66$obj->rrd_graph();
diff --git a/plugin/ntpd.php b/plugin/ntpd.php
index 1260c57..22f9580 100644
--- a/plugin/ntpd.php
+++ b/plugin/ntpd.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# ntpd/ 9# ntpd/
@@ -46,5 +45,4 @@ switch($obj->args['type']) {
46 break; 45 break;
47} 46}
48 47
49collectd_flush($obj->identifiers);
50$obj->rrd_graph(); 48$obj->rrd_graph();
diff --git a/plugin/nut.php b/plugin/nut.php
index b1d1610..f8d7150 100644
--- a/plugin/nut.php
+++ b/plugin/nut.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# nut-XXXX/ 9# nut-XXXX/
@@ -75,5 +74,4 @@ switch($obj->args['type']) {
75 break; 74 break;
76} 75}
77 76
78collectd_flush($obj->identifiers);
79$obj->rrd_graph(); 77$obj->rrd_graph();
diff --git a/plugin/openvpn.php b/plugin/openvpn.php
index 429964b..1ff6dd1 100644
--- a/plugin/openvpn.php
+++ b/plugin/openvpn.php
@@ -3,7 +3,6 @@
3# Collectd OpenVPN plugin 3# Collectd OpenVPN plugin
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'inc/collectd.inc.php';
7 6
8## LAYOUT 7## LAYOUT
9# openvpn-XXXX/ 8# openvpn-XXXX/
@@ -40,5 +39,4 @@ switch(GET('t')) {
40 break; 39 break;
41} 40}
42 41
43collectd_flush($obj->identifiers);
44$obj->rrd_graph(); 42$obj->rrd_graph();
diff --git a/plugin/ping.php b/plugin/ping.php
index 1da00c2..845a6d9 100644
--- a/plugin/ping.php
+++ b/plugin/ping.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# ping/ 9# ping/
@@ -35,5 +34,4 @@ switch($obj->args['type']) {
35 break; 34 break;
36} 35}
37 36
38collectd_flush($obj->identifiers);
39$obj->rrd_graph(); 37$obj->rrd_graph();
diff --git a/plugin/postgresql.php b/plugin/postgresql.php
index 03e5cee..4c2a62f 100644
--- a/plugin/postgresql.php
+++ b/plugin/postgresql.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# postgresql-X/pg_blks-heap_hit.rrd 9# postgresql-X/pg_blks-heap_hit.rrd
@@ -128,5 +127,4 @@ switch($obj->args['type']) {
128 break; 127 break;
129} 128}
130 129
131collectd_flush($obj->identifiers);
132$obj->rrd_graph(); 130$obj->rrd_graph();
diff --git a/plugin/powerdns.php b/plugin/powerdns.php
index 55312e9..d83d67b 100644
--- a/plugin/powerdns.php
+++ b/plugin/powerdns.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9 8
10$obj = new Type_Default($CONFIG, $_GET); 9$obj = new Type_Default($CONFIG, $_GET);
@@ -12,5 +11,4 @@ $obj = new Type_Default($CONFIG, $_GET);
12$obj->rrd_title = sprintf('PowerDNS %s (%s)', $obj->args['type'], $obj->args['pinstance']); 11$obj->rrd_title = sprintf('PowerDNS %s (%s)', $obj->args['type'], $obj->args['pinstance']);
13$obj->rrd_format = '%5.1lf%s'; 12$obj->rrd_format = '%5.1lf%s';
14 13
15collectd_flush($obj->identifiers);
16$obj->rrd_graph(); 14$obj->rrd_graph();
diff --git a/plugin/processes.php b/plugin/processes.php
index 54c1ad7..a35800b 100644
--- a/plugin/processes.php
+++ b/plugin/processes.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# processes/ 9# processes/
@@ -181,5 +180,4 @@ switch($obj->args['type'])
181} 180}
182 181
183 182
184collectd_flush($obj->identifiers);
185$obj->rrd_graph(); 183$obj->rrd_graph();
diff --git a/plugin/sensors.php b/plugin/sensors.php
index ba31487..0ac2ccd 100644
--- a/plugin/sensors.php
+++ b/plugin/sensors.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# sensors-XXXX/ 9# sensors-XXXX/
@@ -34,5 +33,4 @@ switch($obj->args['type']) {
34 break; 33 break;
35} 34}
36 35
37collectd_flush($obj->identifiers);
38$obj->rrd_graph(); 36$obj->rrd_graph();
diff --git a/plugin/snmp.php b/plugin/snmp.php
index 680d94f..4d871a8 100644
--- a/plugin/snmp.php
+++ b/plugin/snmp.php
@@ -3,7 +3,6 @@
3# Collectd snmp plugin 3# Collectd snmp plugin
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'inc/collectd.inc.php';
7 6
8 7
9switch(GET('t')) { 8switch(GET('t')) {
@@ -32,6 +31,5 @@ switch(GET('t')) {
32 31
33$obj->rrd_format = '%5.1lf%s'; 32$obj->rrd_format = '%5.1lf%s';
34 33
35collectd_flush($obj->identifiers);
36$obj->rrd_graph(); 34$obj->rrd_graph();
37 35
diff --git a/plugin/swap.php b/plugin/swap.php
index 983d38d..5b02130 100644
--- a/plugin/swap.php
+++ b/plugin/swap.php
@@ -3,7 +3,6 @@
3# Collectd Swap plugin 3# Collectd Swap plugin
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'inc/collectd.inc.php';
7 6
8## LAYOUT 7## LAYOUT
9# swap/ 8# swap/
@@ -48,5 +47,4 @@ switch(GET('t')) {
48 47
49$obj->rrd_format = '%5.1lf%s'; 48$obj->rrd_format = '%5.1lf%s';
50 49
51collectd_flush($obj->identifiers);
52$obj->rrd_graph(); 50$obj->rrd_graph();
diff --git a/plugin/tail.php b/plugin/tail.php
index 4e23174..91400c7 100644
--- a/plugin/tail.php
+++ b/plugin/tail.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9 8
10$obj = new Type_Default($CONFIG, $_GET); 9$obj = new Type_Default($CONFIG, $_GET);
@@ -27,5 +26,4 @@ if ($CONFIG['version'] < 5) {
27 } 26 }
28} 27}
29 28
30collectd_flush($obj->identifiers);
31$obj->rrd_graph(); 29$obj->rrd_graph();
diff --git a/plugin/tcpconns.php b/plugin/tcpconns.php
index 1e6917a..5c629c5 100644
--- a/plugin/tcpconns.php
+++ b/plugin/tcpconns.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# tcpconns-XXXX/ 9# tcpconns-XXXX/
@@ -15,5 +14,4 @@ $obj->rrd_title = sprintf('TCP Connections (%s)', $obj->args['pinstance']);
15$obj->rrd_vertical = '#'; 14$obj->rrd_vertical = '#';
16$obj->rrd_format = '%5.1lf'; 15$obj->rrd_format = '%5.1lf';
17 16
18collectd_flush($obj->identifiers);
19$obj->rrd_graph(); 17$obj->rrd_graph();
diff --git a/plugin/thermal.php b/plugin/thermal.php
index b2fa74c..fb39ecb 100644
--- a/plugin/thermal.php
+++ b/plugin/thermal.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# thermal-XXXX/ 9# thermal-XXXX/
@@ -22,5 +21,4 @@ switch($obj->args['type']) {
22 break; 21 break;
23} 22}
24 23
25collectd_flush($obj->identifiers);
26$obj->rrd_graph(); 24$obj->rrd_graph();
diff --git a/plugin/uptime.php b/plugin/uptime.php
index 1d432a9..20c44d3 100644
--- a/plugin/uptime.php
+++ b/plugin/uptime.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Uptime.class.php'; 6require_once 'type/Uptime.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# uptime/uptime.rrd 9# uptime/uptime.rrd
@@ -21,5 +20,4 @@ $obj->rrd_title = 'Uptime';
21$obj->rrd_vertical = 'Days'; 20$obj->rrd_vertical = 'Days';
22$obj->rrd_format = '%.1lf'; 21$obj->rrd_format = '%.1lf';
23 22
24collectd_flush($obj->identifiers);
25$obj->rrd_graph(); 23$obj->rrd_graph();
diff --git a/plugin/users.php b/plugin/users.php
index f4cde28..6b3bc4e 100644
--- a/plugin/users.php
+++ b/plugin/users.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# users/users.rrd 9# users/users.rrd
@@ -32,5 +31,4 @@ if ($CONFIG['version'] < 5) {
32 unset($obj->colors['value']); 31 unset($obj->colors['value']);
33} 32}
34 33
35collectd_flush($obj->identifiers);
36$obj->rrd_graph(); 34$obj->rrd_graph();
diff --git a/plugin/varnish.php b/plugin/varnish.php
index 6b199b7..f2f597c 100644
--- a/plugin/varnish.php
+++ b/plugin/varnish.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php'; 6require_once 'type/Default.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10#varnish-default-backend/connections-failures.rrd 9#varnish-default-backend/connections-failures.rrd
@@ -27,5 +26,4 @@ $obj->rrd_format = '%5.1lf%s';
27$obj->rrd_title = sprintf('%s (%s)', ucfirst($obj->args['pinstance']), $obj->args['category']); 26$obj->rrd_title = sprintf('%s (%s)', ucfirst($obj->args['pinstance']), $obj->args['category']);
28$obj->rrd_vertical = 'hits'; 27$obj->rrd_vertical = 'hits';
29 28
30collectd_flush($obj->identifiers);
31$obj->rrd_graph(); 29$obj->rrd_graph();
diff --git a/plugin/vmem.php b/plugin/vmem.php
index 3e1a64c..8fb81ce 100644
--- a/plugin/vmem.php
+++ b/plugin/vmem.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9## LAYOUT 8## LAYOUT
10# vmem/ 9# vmem/
@@ -56,5 +55,4 @@ switch($obj->args['type']) {
56 break; 55 break;
57} 56}
58 57
59collectd_flush($obj->identifiers);
60$obj->rrd_graph(); 58$obj->rrd_graph();
diff --git a/plugin/vserver.php b/plugin/vserver.php
index 8eee8db..27e739f 100644
--- a/plugin/vserver.php
+++ b/plugin/vserver.php
@@ -5,7 +5,6 @@
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericIO.class.php'; 6require_once 'type/GenericIO.class.php';
7require_once 'type/GenericStacked.class.php'; 7require_once 'type/GenericStacked.class.php';
8require_once 'inc/collectd.inc.php';
9 8
10# LAYOUT 9# LAYOUT
11# vserver-XXXX 10# vserver-XXXX
@@ -52,7 +51,6 @@ switch($obj->args['type']) {
52 $obj->rrd_vertical = 'Bytes'; 51 $obj->rrd_vertical = 'Bytes';
53 $obj->rrd_format = '%5.1lf%s'; 52 $obj->rrd_format = '%5.1lf%s';
54 53
55 collectd_flush($obj->identifiers);
56 $obj->rrd_graph(); 54 $obj->rrd_graph();
57 break; 55 break;
58 case 'vs_threads': 56 case 'vs_threads':
@@ -76,7 +74,6 @@ switch($obj->args['type']) {
76 $obj->rrd_vertical = 'Numbers'; 74 $obj->rrd_vertical = 'Numbers';
77 $obj->rrd_format = '%5.1lf%s'; 75 $obj->rrd_format = '%5.1lf%s';
78 76
79 collectd_flush($obj->identifiers);
80 $obj->rrd_graph(); 77 $obj->rrd_graph();
81 break; 78 break;
82 case 'if_octets': 79 case 'if_octets':
@@ -104,7 +101,6 @@ switch($obj->args['type']) {
104 $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; 101 $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1;
105 $obj->rrd_format = '%5.1lf%s'; 102 $obj->rrd_format = '%5.1lf%s';
106 103
107 collectd_flush($obj->identifiers);
108 $obj->rrd_graph(); 104 $obj->rrd_graph();
109 break; 105 break;
110 case 'vs_processes': 106 case 'vs_processes':
@@ -117,7 +113,6 @@ switch($obj->args['type']) {
117 113
118 $obj->rrd_format = '%5.1lf%s'; 114 $obj->rrd_format = '%5.1lf%s';
119 115
120 collectd_flush($obj->identifiers);
121 $obj->rrd_graph(); 116 $obj->rrd_graph();
122 break; 117 break;
123 118
diff --git a/plugin/wireless.php b/plugin/wireless.php
index 70598b5..991a0f3 100644
--- a/plugin/wireless.php
+++ b/plugin/wireless.php
@@ -4,7 +4,6 @@
4 4
5require_once 'conf/common.inc.php'; 5require_once 'conf/common.inc.php';
6require_once 'type/GenericStacked.class.php'; 6require_once 'type/GenericStacked.class.php';
7require_once 'inc/collectd.inc.php';
8 7
9$obj = new Type_GenericStacked($CONFIG, $_GET); 8$obj = new Type_GenericStacked($CONFIG, $_GET);
10$obj->data_sources = array('value'); 9$obj->data_sources = array('value');
@@ -27,5 +26,4 @@ switch($obj->args['type']) {
27 break; 26 break;
28} 27}
29 28
30collectd_flush($obj->identifiers);
31$obj->rrd_graph(); 29$obj->rrd_graph();
diff --git a/plugin/zfs_arc.php b/plugin/zfs_arc.php
index 85f3016..5fc4407 100644
--- a/plugin/zfs_arc.php
+++ b/plugin/zfs_arc.php
@@ -3,7 +3,6 @@
3 3
4require_once 'conf/common.inc.php'; 4require_once 'conf/common.inc.php';
5require_once 'type/Default.class.php'; 5require_once 'type/Default.class.php';
6require_once 'inc/collectd.inc.php';
7 6
8## LAYOUT 7## LAYOUT
9# zfs_arc/ 8# zfs_arc/
@@ -95,5 +94,4 @@ switch($obj->args['type']) {
95 $obj->rrd_vertical = 'ratio'; 94 $obj->rrd_vertical = 'ratio';
96 break; 95 break;
97} 96}
98collectd_flush($obj->identifiers);
99$obj->rrd_graph(); 97$obj->rrd_graph();
diff --git a/type/Base.class.php b/type/Base.class.php
index 2851280..fe31814 100644
--- a/type/Base.class.php
+++ b/type/Base.class.php
@@ -27,6 +27,9 @@ class Type_Base {
27 var $tinstances; 27 var $tinstances;
28 var $identifiers; 28 var $identifiers;
29 29
30 var $flush_socket;
31 var $flush_type;
32
30 function __construct($config, $_get) { 33 function __construct($config, $_get) {
31 $this->datadir = $config['datadir']; 34 $this->datadir = $config['datadir'];
32 $this->rrdtool = $config['rrdtool']; 35 $this->rrdtool = $config['rrdtool'];
@@ -39,6 +42,8 @@ class Type_Base {
39 $this->graph_type = $config['graph_type']; 42 $this->graph_type = $config['graph_type'];
40 $this->negative_io = $config['negative_io']; 43 $this->negative_io = $config['negative_io'];
41 $this->graph_smooth = $config['graph_smooth']; 44 $this->graph_smooth = $config['graph_smooth'];
45 $this->flush_socket = $config['socket'];
46 $this->flush_type = $config['flush_type'];
42 } 47 }
43 48
44 function rainbow_colors() { 49 function rainbow_colors() {
@@ -167,6 +172,8 @@ class Type_Base {
167 } 172 }
168 173
169 function rrd_graph($debug = false) { 174 function rrd_graph($debug = false) {
175 $this->collectd_flush();
176
170 if (!$this->colors) 177 if (!$this->colors)
171 $this->rainbow_colors(); 178 $this->rainbow_colors();
172 179
@@ -295,4 +302,67 @@ class Type_Base {
295 $this->ds_names[$index] = sprintf($format, $value); 302 $this->ds_names[$index] = sprintf($format, $value);
296 } 303 }
297 } 304 }
305
306 function socket_cmd($socket, $cmd) {
307 $r = fwrite($socket, $cmd, strlen($cmd));
308 if ($r === false || $r != strlen($cmd)) {
309 error_log(sprintf('ERROR: Failed to write full command to unix-socket: %d out of %d written',
310 $r === false ? -1 : $r, strlen($cmd)));
311 return FALSE;
312 }
313
314 $resp = fgets($socket,128);
315 if ($resp === false) {
316 error_log(sprintf('ERROR: Failed to read response from collectd for command: %s',
317 trim($cmd)));
318 return FALSE;
319 }
320
321 $n = (int)$resp;
322 while ($n-- > 0)
323 fgets($socket,128);
324
325 return TRUE;
326 }
327
328 # tell collectd to FLUSH all data of the identifier(s)
329 function collectd_flush() {
330 $identifier = $this->identifiers;
331
332 if (!$this->flush_socket)
333 return FALSE;
334
335 if (!$identifier || (is_array($identifier) && count($identifier) == 0) ||
336 !(is_string($identifier) || is_array($identifier)))
337 return FALSE;
338
339 if (!is_array($identifier))
340 $identifier = array($identifier);
341
342 $u_errno = 0;
343 $u_errmsg = '';
344 if (! $socket = @fsockopen($this->flush_socket, 0, $u_errno, $u_errmsg)) {
345 error_log(sprintf('ERROR: Failed to open unix-socket to %s (%d: %s)',
346 $this->flush_socket, $u_errno, $u_errmsg));
347 return FALSE;
348 }
349
350 if ($this->flush_type == 'collectd'){
351 $cmd = 'FLUSH';
352 foreach ($identifier as $val)
353 $cmd .= sprintf(' identifier="%s"', $val);
354 $cmd .= "\n";
355 $this->socket_cmd($socket, $cmd);
356 }
357 elseif ($this->flush_type == 'rrdcached') {
358 foreach ($identifier as $val) {
359 $cmd = sprintf("FLUSH %s.rrd\n", $val);
360 $this->socket_cmd($socket, $cmd);
361 }
362 }
363
364 fclose($socket);
365
366 return TRUE;
367 }
298} 368}