aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorPim van den Berg2011-08-27 18:22:24 +0200
committerPim van den Berg2011-08-27 18:32:38 +0200
commit330c94f4f3437036a50a57f1b3f5ca7e991c2230 (patch)
tree29b916a3aa69f38adcd6ff96bbd4fa12c97e9258
parentplugin/apcups: collectd 5 compatibility (diff)
downloadapt-panopticon_cgp-330c94f4f3437036a50a57f1b3f5ca7e991c2230.zip
apt-panopticon_cgp-330c94f4f3437036a50a57f1b3f5ca7e991c2230.tar.gz
apt-panopticon_cgp-330c94f4f3437036a50a57f1b3f5ca7e991c2230.tar.bz2
apt-panopticon_cgp-330c94f4f3437036a50a57f1b3f5ca7e991c2230.tar.xz
type: escape colons in filenames used in rrd commandline
A colon ':' in a legend argument will mark the end of the legend: http://oss.oetiker.ch/rrdtool/doc/rrdgraph_graph.en.html#INOTES_on_legend_arguments Reported-by: Benjamin Dupuis <poil@quake.fr>
-rw-r--r--type/Default.class.php10
-rw-r--r--type/GenericIO.class.php6
-rw-r--r--type/GenericStacked.class.php6
-rw-r--r--type/Uptime.class.php4
4 files changed, 15 insertions, 11 deletions
diff --git a/type/Default.class.php b/type/Default.class.php
index cc1818a..eaf2e8e 100644
--- a/type/Default.class.php
+++ b/type/Default.class.php
@@ -98,6 +98,10 @@ class Type_Default {
98 return $c['r'].$c['g'].$c['b']; 98 return $c['r'].$c['g'].$c['b'];
99 } 99 }
100 100
101 function rrd_escape($value) {
102 return str_replace(':', '\:', $value);
103 }
104
101 function rrd_files() { 105 function rrd_files() {
102 $files = $this->get_filenames(); 106 $files = $this->get_filenames();
103 107
@@ -234,9 +238,9 @@ class Type_Default {
234 $i=0; 238 $i=0;
235 foreach ($this->tinstances as $tinstance) { 239 foreach ($this->tinstances as $tinstance) {
236 foreach ($this->data_sources as $ds) { 240 foreach ($this->data_sources as $ds) {
237 $rrdgraph[] = sprintf('DEF:min_%s="%s":%s:MIN', crc32hex($sources[$i]), $this->files[$tinstance], $ds); 241 $rrdgraph[] = sprintf('DEF:min_%s="%s":%s:MIN', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds);
238 $rrdgraph[] = sprintf('DEF:avg_%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $this->files[$tinstance], $ds); 242 $rrdgraph[] = sprintf('DEF:avg_%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds);
239 $rrdgraph[] = sprintf('DEF:max_%s="%s":%s:MAX', crc32hex($sources[$i]), $this->files[$tinstance], $ds); 243 $rrdgraph[] = sprintf('DEF:max_%s="%s":%s:MAX', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds);
240 $i++; 244 $i++;
241 } 245 }
242 } 246 }
diff --git a/type/GenericIO.class.php b/type/GenericIO.class.php
index 18a27ea..bc0fdef 100644
--- a/type/GenericIO.class.php
+++ b/type/GenericIO.class.php
@@ -14,9 +14,9 @@ class Type_GenericIO extends Type_Default {
14 $i=0; 14 $i=0;
15 foreach ($this->tinstances as $tinstance) { 15 foreach ($this->tinstances as $tinstance) {
16 foreach ($this->data_sources as $ds) { 16 foreach ($this->data_sources as $ds) {
17 $rrdgraph[] = sprintf('DEF:min_%s%s=%s:%s:MIN', crc32hex($sources[$i]), $raw, $this->files[$tinstance], $ds); 17 $rrdgraph[] = sprintf('DEF:min_%s%s="%s":%s:MIN', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds);
18 $rrdgraph[] = sprintf('DEF:avg_%s%s=%s:%s:AVERAGE', crc32hex($sources[$i]), $raw, $this->files[$tinstance], $ds); 18 $rrdgraph[] = sprintf('DEF:avg_%s%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds);
19 $rrdgraph[] = sprintf('DEF:max_%s%s=%s:%s:MAX', crc32hex($sources[$i]), $raw, $this->files[$tinstance], $ds); 19 $rrdgraph[] = sprintf('DEF:max_%s%s="%s":%s:MAX', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds);
20 $rrdgraph[] = sprintf('VDEF:tot_%1$s=avg_%1$s%2$s,TOTAL', crc32hex($sources[$i]), $raw); 20 $rrdgraph[] = sprintf('VDEF:tot_%1$s=avg_%1$s%2$s,TOTAL', crc32hex($sources[$i]), $raw);
21 $i++; 21 $i++;
22 } 22 }
diff --git a/type/GenericStacked.class.php b/type/GenericStacked.class.php
index e9213de..f47af2a 100644
--- a/type/GenericStacked.class.php
+++ b/type/GenericStacked.class.php
@@ -12,9 +12,9 @@ class Type_GenericStacked extends Type_Default {
12 $i=0; 12 $i=0;
13 foreach ($this->tinstances as $tinstance) { 13 foreach ($this->tinstances as $tinstance) {
14 foreach ($this->data_sources as $ds) { 14 foreach ($this->data_sources as $ds) {
15 $rrdgraph[] = sprintf('DEF:min_%s=%s:%s:MIN', crc32hex($sources[$i]), $this->files[$tinstance], $ds); 15 $rrdgraph[] = sprintf('DEF:min_%s="%s":%s:MIN', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds);
16 $rrdgraph[] = sprintf('DEF:avg_%s=%s:%s:AVERAGE', crc32hex($sources[$i]), $this->files[$tinstance], $ds); 16 $rrdgraph[] = sprintf('DEF:avg_%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds);
17 $rrdgraph[] = sprintf('DEF:max_%s=%s:%s:MAX', crc32hex($sources[$i]), $this->files[$tinstance], $ds); 17 $rrdgraph[] = sprintf('DEF:max_%s="%s":%s:MAX', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds);
18 $i++; 18 $i++;
19 } 19 }
20 } 20 }
diff --git a/type/Uptime.class.php b/type/Uptime.class.php
index 04033a9..cadb8dd 100644
--- a/type/Uptime.class.php
+++ b/type/Uptime.class.php
@@ -12,8 +12,8 @@ class Type_Uptime extends Type_Default {
12 $i=0; 12 $i=0;
13 foreach ($this->tinstances as $tinstance) { 13 foreach ($this->tinstances as $tinstance) {
14 foreach ($this->data_sources as $ds) { 14 foreach ($this->data_sources as $ds) {
15 $rrdgraph[] = sprintf('DEF:avg_%s=%s:%s:AVERAGE', crc32hex($sources[$i]), $this->files[$tinstance], $ds); 15 $rrdgraph[] = sprintf('DEF:avg_%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds);
16 $rrdgraph[] = sprintf('DEF:max_%s=%s:%s:MAX', crc32hex($sources[$i]), $this->files[$tinstance], $ds); 16 $rrdgraph[] = sprintf('DEF:max_%s="%s":%s:MAX', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds);
17 17
18 $rrdgraph[] = sprintf('CDEF:c_avg_%s=avg_%1$s,86400,/', crc32hex($sources[$i])); 18 $rrdgraph[] = sprintf('CDEF:c_avg_%s=avg_%1$s,86400,/', crc32hex($sources[$i]));
19 $rrdgraph[] = sprintf('CDEF:c_max_%s=max_%1$s,86400,/', crc32hex($sources[$i])); 19 $rrdgraph[] = sprintf('CDEF:c_max_%s=max_%1$s,86400,/', crc32hex($sources[$i]));