aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/type
diff options
context:
space:
mode:
authorJakob Haufe2010-02-09 18:33:27 +0100
committerPim van den Berg2010-02-16 00:53:55 +0100
commit596dd7d41468ab8ffb3b821163b486e6629e2212 (patch)
treec3bdac629f213f496c05f36fcfb01b41368678bb /type
parentadd compatibility if rrdinfo doesn't work as expected (diff)
downloadapt-panopticon_cgp-596dd7d41468ab8ffb3b821163b486e6629e2212.zip
apt-panopticon_cgp-596dd7d41468ab8ffb3b821163b486e6629e2212.tar.gz
apt-panopticon_cgp-596dd7d41468ab8ffb3b821163b486e6629e2212.tar.bz2
apt-panopticon_cgp-596dd7d41468ab8ffb3b821163b486e6629e2212.tar.xz
make rrdfiles using utf8 and spaces work
Diffstat (limited to 'type')
-rw-r--r--type/Default.class.php32
1 files changed, 16 insertions, 16 deletions
diff --git a/type/Default.class.php b/type/Default.class.php
index ade3a16..9e2e6b7 100644
--- a/type/Default.class.php
+++ b/type/Default.class.php
@@ -78,10 +78,11 @@ class Type_Default {
78 $files = $this->get_filenames(); 78 $files = $this->get_filenames();
79 79
80 foreach($files as $filename) { 80 foreach($files as $filename) {
81 preg_match("#^$this->datadir/{$this->args['host']}/[\w\d]+-?([\w\d-]+)?/[\w\d]+-?([\w\d-]+)?\.rrd#", $filename, $matches); 81 $basename=basename($filename,'.rrd');
82 $instance=substr($basename,strpos($basename,'-')+1);
82 83
83 $this->tinstances[] = $matches[2]; 84 $this->tinstances[] = $instance;
84 $this->files[$matches[2]] = $filename; 85 $this->files[$instance] = $filename;
85 } 86 }
86 87
87 sort($this->tinstances); 88 sort($this->tinstances);
@@ -103,8 +104,7 @@ class Type_Default {
103 function file2identifier($files) { 104 function file2identifier($files) {
104 foreach($files as $key => $file) { 105 foreach($files as $key => $file) {
105 if (is_file($file)) { 106 if (is_file($file)) {
106 $files[$key] = preg_replace("#^$this->datadir/#", '', $files[$key]); 107 $files[$key] = basename($files[$key], '.rrd');
107 $files[$key] = preg_replace('#\.rrd$#', '', $files[$key]);
108 } 108 }
109 } 109 }
110 110
@@ -167,29 +167,29 @@ class Type_Default {
167 $i=0; 167 $i=0;
168 foreach ($this->tinstances as $tinstance) { 168 foreach ($this->tinstances as $tinstance) {
169 foreach ($this->data_sources as $ds) { 169 foreach ($this->data_sources as $ds) {
170 $rrdgraph[] = sprintf('DEF:min_%s=%s:%s:MIN', $sources[$i], $this->files[$tinstance], $ds); 170 $rrdgraph[] = sprintf('DEF:min_%s="%s":%s:MIN', crc32hex($sources[$i]), $this->files[$tinstance], $ds);
171 $rrdgraph[] = sprintf('DEF:avg_%s=%s:%s:AVERAGE', $sources[$i], $this->files[$tinstance], $ds); 171 $rrdgraph[] = sprintf('DEF:avg_%s="%s":%s:AVERAGE', crc32hex($sources[$i]), $this->files[$tinstance], $ds);
172 $rrdgraph[] = sprintf('DEF:max_%s=%s:%s:MAX', $sources[$i], $this->files[$tinstance], $ds); 172 $rrdgraph[] = sprintf('DEF:max_%s="%s":%s:MAX', crc32hex($sources[$i]), $this->files[$tinstance], $ds);
173 $i++; 173 $i++;
174 } 174 }
175 } 175 }
176 176
177 if(count($this->files)<=1) { 177 if(count($this->files)<=1) {
178 foreach ($sources as $source) { 178 foreach ($sources as $source) {
179 $rrdgraph[] = sprintf('AREA:max_%s#%s', $source, $this->get_faded_color($this->colors[$source])); 179 $rrdgraph[] = sprintf('AREA:max_%s#%s', crc32hex($source), $this->get_faded_color($this->colors[$source]));
180 $rrdgraph[] = sprintf('AREA:min_%s#%s', $source, 'ffffff'); 180 $rrdgraph[] = sprintf('AREA:min_%s#%s', crc32hex($source), 'ffffff');
181 break; # only 1 area to draw 181 break; # only 1 area to draw
182 } 182 }
183 } 183 }
184 184
185 foreach ($sources as $source) { 185 foreach($sources as $source) {
186 $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source; 186 $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source;
187 $color = is_array($this->colors) ? $this->colors[$source]: $this->colors; 187 $color = is_array($this->colors) ? $this->colors[$source]: $this->colors;
188 $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', $source, $this->validate_color($color), $dsname); 188 $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', crc32hex($source), $this->validate_color($color), $dsname);
189 $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', $source, $this->rrd_format); 189 $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', crc32hex($source), $this->rrd_format);
190 $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', $source, $this->rrd_format); 190 $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', crc32hex($source), $this->rrd_format);
191 $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', $source, $this->rrd_format); 191 $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', crc32hex($source), $this->rrd_format);
192 $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\\l\'', $source, $this->rrd_format); 192 $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\\l\'', crc32hex($source), $this->rrd_format);
193 } 193 }
194 194
195 return $rrdgraph; 195 return $rrdgraph;