aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.htaccess4
-rw-r--r--conf/config.php3
-rw-r--r--detail.php7
-rw-r--r--inc/collectd.inc.php21
-rw-r--r--inc/functions.inc.php15
-rw-r--r--inc/html.inc.php31
-rw-r--r--js/CGP.js124
-rw-r--r--rrd.php24
-rw-r--r--type/Default.class.php80
-rw-r--r--type/GenericIO.class.php18
-rw-r--r--type/GenericStacked.class.php16
-rw-r--r--type/Uptime.class.php16
12 files changed, 298 insertions, 61 deletions
diff --git a/.htaccess b/.htaccess
index 956f31c..66eaee0 100644
--- a/.htaccess
+++ b/.htaccess
@@ -1,4 +1,6 @@
1Options -Indexes 1Options -Indexes
2 2
3RewriteEngine On 3RewriteEngine On
4RewriteRule ^.git(ignore|/) - [F,L] 4RewriteRule ^.git(ignore|/) - [F,L]
5
6RewriteRule ^rrd/(.*) rrd.php?path=$1
diff --git a/conf/config.php b/conf/config.php
index 288e085..99190f1 100644
--- a/conf/config.php
+++ b/conf/config.php
@@ -42,6 +42,9 @@ $CONFIG['term'] = array(
42# show graphs in bits or bytes 42# show graphs in bits or bytes
43$CONFIG['network_datasize'] = 'bytes'; 43$CONFIG['network_datasize'] = 'bytes';
44 44
45# png or canvas graphs
46$CONFIG['graph_type'] = 'png';
47
45# browser cache time for the graphs (in seconds) 48# browser cache time for the graphs (in seconds)
46$CONFIG['cache'] = 90; 49$CONFIG['cache'] = 90;
47 50
diff --git a/detail.php b/detail.php
index 5aa38de..c7df632 100644
--- a/detail.php
+++ b/detail.php
@@ -47,7 +47,12 @@ foreach($CONFIG['term'] as $key => $s) {
47} 47}
48print "</ul>\n"; 48print "</ul>\n";
49 49
50printf('<img src="%s%s">'."\n", $CONFIG['weburl'], build_url('graph.php', $_GET)); 50if ($CONFIG['graph_type'] == 'canvas') {
51 chdir($CONFIG['webdir']);
52 include $CONFIG['webdir'].'/plugin/'.$plugin.'.php';
53} else {
54 printf('<img src="%s%s">'."\n", $CONFIG['weburl'], build_url('graph.php', $_GET));
55}
51echo '</div>'; 56echo '</div>';
52 57
53html_end(); 58html_end();
diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php
index ad15774..1df8bb0 100644
--- a/inc/collectd.inc.php
+++ b/inc/collectd.inc.php
@@ -169,12 +169,21 @@ function graphs_from_plugin($host, $plugin, $overview=false) {
169 ? $CONFIG['time_range'][$plugin] 169 ? $CONFIG['time_range'][$plugin]
170 : $CONFIG['time_range']['default']; 170 : $CONFIG['time_range']['default'];
171 171
172 printf('<a href="%s%s"><img src="%s%s"></a>'."\n", 172 if ($CONFIG['graph_type'] == 'canvas') {
173 $CONFIG['weburl'], 173 chdir($CONFIG['webdir']);
174 build_url('detail.php', $items, $time), 174 isset($items['p']) ? $_GET['p'] = $items['p'] : $_GET['p'] = '';
175 $CONFIG['weburl'], 175 isset($items['pi']) ? $_GET['pi'] = $items['pi'] : $_GET['pi'] = '';
176 build_url('graph.php', $items, $time) 176 isset($items['t']) ? $_GET['t'] = $items['t'] : $_GET['t'] = '';
177 ); 177 isset($items['ti']) ? $_GET['ti'] = $items['ti'] : $_GET['ti'] = '';
178 include $CONFIG['webdir'].'/plugin/'.$plugin.'.php';
179 } else {
180 printf('<a href="%s%s"><img src="%s%s"></a>'."\n",
181 $CONFIG['weburl'],
182 build_url('detail.php', $items, $time),
183 $CONFIG['weburl'],
184 build_url('graph.php', $items, $time)
185 );
186 }
178 } 187 }
179} 188}
180 189
diff --git a/inc/functions.inc.php b/inc/functions.inc.php
index a72a589..6642e51 100644
--- a/inc/functions.inc.php
+++ b/inc/functions.inc.php
@@ -30,6 +30,21 @@ function validate_get($value, $type) {
30 return $value; 30 return $value;
31} 31}
32 32
33function validateRRDPath($base, $path) {
34 $realpath = realpath(sprintf('%s/%s', $base, $path));
35
36 if (strpos($realpath, $base) === false)
37 return false;
38
39 if (strpos($realpath, $base) !== 0)
40 return false;
41
42 if (!preg_match('/\.rrd$/', $realpath))
43 return false;
44
45 return $realpath;
46}
47
33function crc32hex($str) { 48function crc32hex($str) {
34 return sprintf("%x",crc32($str)); 49 return sprintf("%x",crc32($str));
35} 50}
diff --git a/inc/html.inc.php b/inc/html.inc.php
index a9e6a94..a0e2c8d 100644
--- a/inc/html.inc.php
+++ b/inc/html.inc.php
@@ -19,6 +19,26 @@ function html_start() {
19 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 19 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
20 <title>CGP{$path}</title> 20 <title>CGP{$path}</title>
21 <link rel="stylesheet" href="{$CONFIG['weburl']}layout/style.css" type="text/css"> 21 <link rel="stylesheet" href="{$CONFIG['weburl']}layout/style.css" type="text/css">
22
23EOT;
24
25 if ($CONFIG['graph_type'] == 'canvas') {
26 echo <<<EOT
27 <script type="text/javascript" src="{$CONFIG['weburl']}js/sprintf.js"></script>
28 <script type="text/javascript" src="{$CONFIG['weburl']}js/strftime.js"></script>
29 <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdRpn.js"></script>
30 <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdTime.js"></script>
31 <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdGraph.js"></script>
32 <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdGfxCanvas.js"></script>
33 <script type="text/javascript" src="{$CONFIG['weburl']}js/binaryXHR.js"></script>
34 <script type="text/javascript" src="{$CONFIG['weburl']}js/rrdFile.js"></script>
35 <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdDataFile.js"></script>
36 <script type="text/javascript" src="{$CONFIG['weburl']}js/RrdCmdLine.js"></script>
37
38EOT;
39 }
40
41echo <<<EOT
22</head> 42</head>
23<body> 43<body>
24 44
@@ -52,6 +72,17 @@ function html_end() {
52<div id="footer"> 72<div id="footer">
53<hr><span class="small"><a href="http://pommi.nethuis.nl/category/cgp/" rel="external">Collectd Graph Panel</a> ({$version}) is distributed under the <a href="{$CONFIG['weburl']}doc/LICENSE" rel="licence">GNU General Public License (GPLv3)</a></span> 73<hr><span class="small"><a href="http://pommi.nethuis.nl/category/cgp/" rel="external">Collectd Graph Panel</a> ({$version}) is distributed under the <a href="{$CONFIG['weburl']}doc/LICENSE" rel="licence">GNU General Public License (GPLv3)</a></span>
54</div> 74</div>
75
76EOT;
77
78 if ($CONFIG['graph_type'] == 'canvas') {
79 echo <<<EOT
80<script type="text/javascript" src="{$CONFIG['weburl']}js/CGP.js"></script>
81
82EOT;
83 }
84
85echo <<<EOT
55</body> 86</body>
56</html> 87</html>
57EOT; 88EOT;
diff --git a/js/CGP.js b/js/CGP.js
new file mode 100644
index 0000000..3c9ea90
--- /dev/null
+++ b/js/CGP.js
@@ -0,0 +1,124 @@
1var mouse_move = function (e) {
2 if (this.rrdgraph.mousedown) {
3 var factor = (this.rrdgraph.end - this.rrdgraph.start) / this.rrdgraph.xsize;
4 var x = e.pageX - this.offsetLeft;
5 var diff = x - this.rrdgraph.mousex;
6 var difffactor = Math.abs(Math.round(diff*factor));
7 if (diff > 0) {
8 this.rrdgraph.end -= difffactor;
9 this.rrdgraph.start -= difffactor;
10 } else {
11 this.rrdgraph.end += difffactor;
12 this.rrdgraph.start += difffactor;
13 }
14 this.rrdgraph.mousex = x;
15 try {
16 this.rrdgraph.graph_paint();
17 } catch (e) {
18 alert(e+"\n"+e.stack);
19 }
20 }
21};
22var mouse_up = function (e) {
23 this.rrdgraph.mousedown = false;
24 this.style.cursor="default";
25};
26var mouse_down = function (e) {
27 var x = e.pageX - this.offsetLeft;
28 this.rrdgraph.mousedown = true;
29 this.rrdgraph.mousex = x;
30 this.style.cursor="move";
31};
32var mouse_scroll = function (e) {
33 e = e ? e : window.event;
34 var wheel = e.detail ? e.detail * -1 : e.wheelDelta / 40;
35 var cstime = this.stime[this.stidx];
36 if (wheel < 0) {
37 this.stidx++;
38 if (this.stidx >= this.stlen) this.stidx = this.stlen-1;
39 } else {
40 this.stidx--;
41 if (this.stidx < 0) this.stidx = 0;
42 }
43 if (cstime !== this.stime[this.stidx]) {
44 var middle = this.rrdgraph.start + Math.abs(Math.round((this.rrdgraph.end - this.rrdgraph.start)/2));
45 this.rrdgraph.start = Math.round(middle - this.stime[this.stidx]/2);
46 this.rrdgraph.end = this.rrdgraph.start + this.stime[this.stidx];
47
48 try {
49 this.rrdgraph.graph_paint();
50 } catch (e) {
51 alert(e+"\n"+e.stack);
52 }
53 }
54
55 if(e.stopPropagation)
56 e.stopPropagation();
57 if(e.preventDefault)
58 e.preventDefault();
59 e.cancelBubble = true;
60 e.cancel = true;
61 e.returnValue = false;
62 return false;
63};
64
65function draw(id) {
66 RrdGraph.prototype.mousex = 0;
67 RrdGraph.prototype.mousedown = false;
68
69 var cmdline = document.getElementById(id).innerHTML;
70 var gfx = new RrdGfxCanvas(id);
71 var fetch = new RrdDataFile();
72 var rrdcmdline = null;
73
74 try {
75 rrdcmdline = new RrdCmdLine(gfx, fetch, cmdline);
76 } catch (e) {
77 alert(e+"\n"+e.stack);
78 }
79
80 var rrdgraph = rrdcmdline.graph;
81
82 gfx.canvas.stime = [ 300, 600, 900, 1200, 1800, 3600, 7200, 21600, 43200, 86400, 172800, 604800, 2592000, 5184000, 15768000, 31536000 ];
83 gfx.canvas.stlen = gfx.canvas.stime.length;
84 gfx.canvas.stidx = 0;
85
86 gfx.canvas.rrdgraph = rrdgraph;
87 gfx.canvas.removeEventListener('mousemove', mouse_move, false);
88 gfx.canvas.addEventListener('mousemove', mouse_move, false);
89 gfx.canvas.removeEventListener('mouseup', mouse_up, false);
90 gfx.canvas.addEventListener('mouseup', mouse_up, false);
91 gfx.canvas.removeEventListener('mousedown', mouse_down, false);
92 gfx.canvas.addEventListener('mousedown', mouse_down, false);
93 gfx.canvas.removeEventListener('mouseout', mouse_up, false);
94 gfx.canvas.addEventListener('mouseout', mouse_up, false);
95 gfx.canvas.removeEventListener('DOMMouseScroll', mouse_scroll, false);
96 gfx.canvas.addEventListener('DOMMouseScroll', mouse_scroll, false);
97 gfx.canvas.removeEventListener('mousewheel', mouse_scroll, false);
98 gfx.canvas.addEventListener('mousewheel', mouse_scroll, false);
99
100 var diff = rrdgraph.end - rrdgraph.start;
101 for (var i=0; i < gfx.canvas.stlen; i++) {
102 if (gfx.canvas.stime[i] >= diff) break;
103 }
104 if (i === gfx.canvas.stlen) gfx.canvas.stidx = gfx.canvas.stlen-1;
105 else gfx.canvas.stidx = i;
106
107 try {
108 rrdgraph.graph_paint();
109 } catch (e) {
110 alert(e+"\n"+e.stack);
111 }
112}
113
114function drawAll()
115{
116 var list=[];
117 var a=document.getElementsByClassName('rrd');
118 for (var i=0,l=a.length;i<l;i++)
119 {
120 draw(a[i].getAttribute('id'))
121 }
122}
123
124window.onload = drawAll()
diff --git a/rrd.php b/rrd.php
new file mode 100644
index 0000000..58614a0
--- /dev/null
+++ b/rrd.php
@@ -0,0 +1,24 @@
1<?php
2
3require_once 'conf/common.inc.php';
4require_once 'inc/functions.inc.php';
5require_once 'inc/html.inc.php';
6
7if ($file = validateRRDPath($CONFIG['datadir'], $_GET['path'])) {
8 header('Content-Type: application/octet-stream');
9 header('Content-Disposition: attachment; filename='.basename($file));
10 header("Expires: " .date(DATE_RFC822,strtotime($CONFIG['cache']." seconds")));
11 ob_clean();
12 flush();
13 readfile($file);
14} else {
15 header('HTTP/1.0 403 Forbidden');
16
17 html_start();
18 echo <<<EOT
19<h2>Forbidden</h2>
20<p><a href="{$CONFIG['weburl']}">Return home...</a></p>
21
22EOT;
23 html_end();
24}
diff --git a/type/Default.class.php b/type/Default.class.php
index 514d1c1..c9220fa 100644
--- a/type/Default.class.php
+++ b/type/Default.class.php
@@ -36,6 +36,7 @@ class Type_Default {
36 if (empty($this->width)) $this->width = $config['width']; 36 if (empty($this->width)) $this->width = $config['width'];
37 $this->heigth = GET('y'); 37 $this->heigth = GET('y');
38 if (empty($this->heigth)) $this->heigth = $config['heigth']; 38 if (empty($this->heigth)) $this->heigth = $config['heigth'];
39 $this->graph_type = $config['graph_type'];
39 } 40 }
40 41
41 function rainbow_colors() { 42 function rainbow_colors() {
@@ -108,6 +109,13 @@ class Type_Default {
108 return str_replace(':', '\:', $value); 109 return str_replace(':', '\:', $value);
109 } 110 }
110 111
112 function parse_filename($file) {
113 if ($this->graph_type == 'canvas') {
114 $file = 'rrd' . str_replace($this->datadir, '', $file);
115 }
116 return $this->rrd_escape($file);
117 }
118
111 function rrd_files() { 119 function rrd_files() {
112 $files = $this->get_filenames(); 120 $files = $this->get_filenames();
113 121
@@ -153,35 +161,51 @@ class Type_Default {
153 return $files; 161 return $files;
154 } 162 }
155 163
156 function rrd_graph($debug=false) { 164 function rrd_graph($debug = false) {
157 if (!$this->colors) 165 if (!$this->colors)
158 $this->rainbow_colors(); 166 $this->rainbow_colors();
159 167
160 $graphdata = $this->rrd_gen_graph(); 168 $graphdata = $this->rrd_gen_graph();
161 169
162 if(!$debug) { 170 $style = $debug !== false ? $debug : $this->graph_type;
163 # caching 171 switch ($style) {
164 if (is_numeric($this->cache) && $this->cache > 0) 172 case 'cmd':
165 header("Expires: " . date(DATE_RFC822,strtotime($this->cache." seconds"))); 173 print '<pre>';
166 header("content-type: image/png"); 174 foreach ($graphdata as $d) {
167 $graphdata = implode(' ', $graphdata); 175 printf("%s \\\n", $d);
168 echo `$graphdata`; 176 }
169 } elseif ($debug == 'cmd') { 177 print '</pre>';
170 print '<pre>'; 178 break;
171 foreach ($graphdata as $d) { 179 case 'canvas':
172 printf("%s \\\n", $d); 180 printf('<canvas id="%s" class="rrd">', sha1(serialize($graphdata)));
173 } 181 foreach ($graphdata as $d) {
174 print '</pre>'; 182 printf("%s\n", $d);
175 } else { 183 }
176 print '<pre>'; 184 print '</canvas>';
177 print_r($graphdata); 185 break;
178 print '</pre>'; 186 case 'debug':
187 case 1:
188 print '<pre>';
189 print_r($graphdata);
190 print '</pre>';
191 break;
192 case 'png':
193 default:
194 # caching
195 if (is_numeric($this->cache) && $this->cache > 0)
196 header("Expires: " . date(DATE_RFC822,strtotime($this->cache." seconds")));
197 header("content-type: image/png");
198 $graphdata = implode(' ', $graphdata);
199 echo `$graphdata`;
200 break;
179 } 201 }
180 } 202 }
181 203
182 function rrd_options() { 204 function rrd_options() {
183 $rrdgraph[] = $this->rrdtool; 205 if ($this->graph_type != 'canvas') {
184 $rrdgraph[] = 'graph - -a PNG'; 206 $rrdgraph[] = $this->rrdtool;
207 $rrdgraph[] = 'graph - -a PNG';
208 }
185 if ($this->rrdtool_opts != '') 209 if ($this->rrdtool_opts != '')
186 $rrdgraph[] = $this->rrdtool_opts; 210 $rrdgraph[] = $this->rrdtool_opts;
187 $rrdgraph[] = sprintf('-w %d', is_numeric($this->width) ? $this->width : 400); 211 $rrdgraph[] = sprintf('-w %d', is_numeric($this->width) ? $this->width : 400);
@@ -260,9 +284,9 @@ class Type_Default {
260 $i=0; 284 $i=0;
261 foreach ($this->tinstances as $tinstance) { 285 foreach ($this->tinstances as $tinstance) {
262 foreach ($this->data_sources as $ds) { 286 foreach ($this->data_sources as $ds) {
263 $rrdgraph[] = sprintf('DEF:min_%s%s="%s":%s:MIN', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 287 $rrdgraph[] = sprintf('DEF:min_%s%s=%s:%s:MIN', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
264 $rrdgraph[] = sprintf('DEF:avg_%s%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 288 $rrdgraph[] = sprintf('DEF:avg_%s%s=%s:%s:AVERAGE', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
265 $rrdgraph[] = sprintf('DEF:max_%s%s="%s":%s:MAX', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 289 $rrdgraph[] = sprintf('DEF:max_%s%s=%s:%s:MAX', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
266 $i++; 290 $i++;
267 } 291 }
268 } 292 }
@@ -292,11 +316,11 @@ class Type_Default {
292 foreach ($sources as $source) { 316 foreach ($sources as $source) {
293 $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source; 317 $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source;
294 $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]): $this->colors; 318 $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]): $this->colors;
295 $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname)); 319 $rrdgraph[] = sprintf('"LINE1:avg_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname));
296 $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', crc32hex($source), $this->rrd_format); 320 $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format);
297 $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', crc32hex($source), $this->rrd_format); 321 $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format);
298 $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', crc32hex($source), $this->rrd_format); 322 $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format);
299 $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\\l\'', crc32hex($source), $this->rrd_format); 323 $rrdgraph[] = sprintf('"GPRINT:avg_%s:LAST:%s Last\\l"', crc32hex($source), $this->rrd_format);
300 } 324 }
301 325
302 return $rrdgraph; 326 return $rrdgraph;
diff --git a/type/GenericIO.class.php b/type/GenericIO.class.php
index 42314fd..0cf3e22 100644
--- a/type/GenericIO.class.php
+++ b/type/GenericIO.class.php
@@ -15,9 +15,9 @@ class Type_GenericIO extends Type_Default {
15 $i=0; 15 $i=0;
16 foreach ($this->tinstances as $tinstance) { 16 foreach ($this->tinstances as $tinstance) {
17 foreach ($this->data_sources as $ds) { 17 foreach ($this->data_sources as $ds) {
18 $rrdgraph[] = sprintf('DEF:min_%s%s="%s":%s:MIN', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 18 $rrdgraph[] = sprintf('DEF:min_%s%s=%s:%s:MIN', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
19 $rrdgraph[] = sprintf('DEF:avg_%s%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 19 $rrdgraph[] = sprintf('DEF:avg_%s%s=%s:%s:AVERAGE', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
20 $rrdgraph[] = sprintf('DEF:max_%s%s="%s":%s:MAX', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 20 $rrdgraph[] = sprintf('DEF:max_%s%s=%s:%s:MAX', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
21 if (!$this->scale) 21 if (!$this->scale)
22 $rrdgraph[] = sprintf('VDEF:tot_%s=avg_%1$s,TOTAL', crc32hex($sources[$i])); 22 $rrdgraph[] = sprintf('VDEF:tot_%s=avg_%1$s,TOTAL', crc32hex($sources[$i]));
23 $i++; 23 $i++;
@@ -52,12 +52,12 @@ class Type_GenericIO extends Type_Default {
52 52
53 foreach($sources as $source) { 53 foreach($sources as $source) {
54 $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source; 54 $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source;
55 $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', crc32hex($source), $this->colors[$source], $this->rrd_escape($dsname)); 55 $rrdgraph[] = sprintf('"LINE1:avg_%s#%s:%s"', crc32hex($source), $this->colors[$source], $this->rrd_escape($dsname));
56 $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', crc32hex($source), $this->rrd_format); 56 $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format);
57 $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', crc32hex($source), $this->rrd_format); 57 $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format);
58 $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', crc32hex($source), $this->rrd_format); 58 $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format);
59 $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\'', crc32hex($source), $this->rrd_format); 59 $rrdgraph[] = sprintf('"GPRINT:avg_%s:LAST:%s Last"', crc32hex($source), $this->rrd_format);
60 $rrdgraph[] = sprintf('GPRINT:tot_%s:\'%s Total\l\'',crc32hex($source), $this->rrd_format); 60 $rrdgraph[] = sprintf('"GPRINT:tot_%s:%s Total\l"',crc32hex($source), $this->rrd_format);
61 } 61 }
62 62
63 return $rrdgraph; 63 return $rrdgraph;
diff --git a/type/GenericStacked.class.php b/type/GenericStacked.class.php
index 7c65ddd..5d1a556 100644
--- a/type/GenericStacked.class.php
+++ b/type/GenericStacked.class.php
@@ -15,9 +15,9 @@ class Type_GenericStacked extends Type_Default {
15 $i=0; 15 $i=0;
16 foreach ($this->tinstances as $tinstance) { 16 foreach ($this->tinstances as $tinstance) {
17 foreach ($this->data_sources as $ds) { 17 foreach ($this->data_sources as $ds) {
18 $rrdgraph[] = sprintf('DEF:min_%s%s="%s":%s:MIN', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 18 $rrdgraph[] = sprintf('DEF:min_%s%s=%s:%s:MIN', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
19 $rrdgraph[] = sprintf('DEF:avg_%s%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 19 $rrdgraph[] = sprintf('DEF:avg_%s%s=%s:%s:AVERAGE', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
20 $rrdgraph[] = sprintf('DEF:max_%s%s="%s":%s:MAX', crc32hex($sources[$i]), $raw, $this->rrd_escape($this->files[$tinstance]), $ds); 20 $rrdgraph[] = sprintf('DEF:max_%s%s=%s:%s:MAX', crc32hex($sources[$i]), $raw, $this->parse_filename($this->files[$tinstance]), $ds);
21 $i++; 21 $i++;
22 } 22 }
23 } 23 }
@@ -51,11 +51,11 @@ class Type_GenericStacked extends Type_Default {
51 foreach ($sources as $source) { 51 foreach ($sources as $source) {
52 $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source; 52 $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source;
53 $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]) : $this->colors; 53 $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]) : $this->colors;
54 $rrdgraph[] = sprintf('LINE1:area_%s#%s:\'%s\'', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname)); 54 $rrdgraph[] = sprintf('"LINE1:area_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname));
55 $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', crc32hex($source), $this->rrd_format); 55 $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format);
56 $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', crc32hex($source), $this->rrd_format); 56 $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format);
57 $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', crc32hex($source), $this->rrd_format); 57 $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format);
58 $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\\l\'', crc32hex($source), $this->rrd_format); 58 $rrdgraph[] = sprintf('"GPRINT:avg_%s:LAST:%s Last\\l"', crc32hex($source), $this->rrd_format);
59 } 59 }
60 60
61 return $rrdgraph; 61 return $rrdgraph;
diff --git a/type/Uptime.class.php b/type/Uptime.class.php
index aa91a6e..17bcb9a 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->rrd_escape($this->files[$tinstance]), $ds); 15 $rrdgraph[] = sprintf('DEF:avg_%s=%s:%s:AVERAGE', crc32hex($sources[$i]), $this->parse_filename($this->files[$tinstance]), $ds);
16 $rrdgraph[] = sprintf('DEF:max_%s="%s":%s:MAX', crc32hex($sources[$i]), $this->rrd_escape($this->files[$tinstance]), $ds); 16 $rrdgraph[] = sprintf('DEF:max_%s=%s:%s:MAX', crc32hex($sources[$i]), $this->parse_filename($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]));
@@ -45,16 +45,16 @@ class Type_Uptime extends Type_Default {
45 $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]) : $this->colors; 45 $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]) : $this->colors;
46 46
47 //current value 47 //current value
48 $rrdgraph[] = sprintf('LINE1:area_%s#%s:\'%s\'', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname)); 48 $rrdgraph[] = sprintf('"LINE1:area_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname));
49 $rrdgraph[] = sprintf('GPRINT:c_avg_%s:LAST:\'%s days\\l\'', crc32hex($source), $this->rrd_format); 49 $rrdgraph[] = sprintf('"GPRINT:c_avg_%s:LAST:%s days\\l"', crc32hex($source), $this->rrd_format);
50 50
51 //max value 51 //max value
52 $rrdgraph[] = sprintf('LINE1:v_max_%s#FF0000:\'Maximum\':dashes', crc32hex($source)); 52 $rrdgraph[] = sprintf('"LINE1:v_max_%s#FF0000:Maximum:dashes"', crc32hex($source));
53 $rrdgraph[] = sprintf('GPRINT:v_max_%s:\'%s days\\l\'', crc32hex($source), $this->rrd_format); 53 $rrdgraph[] = sprintf('"GPRINT:v_max_%s:%s days\\l"', crc32hex($source), $this->rrd_format);
54 54
55 //avg value 55 //avg value
56 $rrdgraph[] = sprintf('LINE1:v_avg_%s#0000FF:\'Average\':dashes', crc32hex($source)); 56 $rrdgraph[] = sprintf('"LINE1:v_avg_%s#0000FF:Average:dashes"', crc32hex($source));
57 $rrdgraph[] = sprintf('GPRINT:v_avg_%s:\'%s days\\l\'', crc32hex($source), $this->rrd_format); 57 $rrdgraph[] = sprintf('"GPRINT:v_avg_%s:%s days\\l"', crc32hex($source), $this->rrd_format);
58 } 58 }
59 59
60 return $rrdgraph; 60 return $rrdgraph;