aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/type
diff options
context:
space:
mode:
authorPim van den Berg2014-05-03 18:15:12 +0200
committerPim van den Berg2014-05-03 19:21:36 +0200
commitedae75c21a8f657dd6cc9ace9e8e844ef337a951 (patch)
treeda0c2b4a1ef35a3d2d8c129925e257f6a6f7fbe3 /type
parenttype/base: set default values for rrd_title and rrd_format (diff)
downloadapt-panopticon_cgp-edae75c21a8f657dd6cc9ace9e8e844ef337a951.zip
apt-panopticon_cgp-edae75c21a8f657dd6cc9ace9e8e844ef337a951.tar.gz
apt-panopticon_cgp-edae75c21a8f657dd6cc9ace9e8e844ef337a951.tar.bz2
apt-panopticon_cgp-edae75c21a8f657dd6cc9ace9e8e844ef337a951.tar.xz
rename ds_names and dsname to legend
This had nothing to do with an RRD data source.
Diffstat (limited to 'type')
-rw-r--r--type/Base.class.php26
-rw-r--r--type/Default.class.php4
-rw-r--r--type/GenericIO.class.php4
-rw-r--r--type/GenericStacked.class.php4
-rw-r--r--type/Uptime.class.php4
5 files changed, 21 insertions, 21 deletions
diff --git a/type/Base.class.php b/type/Base.class.php
index e1aae19..7c06e5d 100644
--- a/type/Base.class.php
+++ b/type/Base.class.php
@@ -11,7 +11,7 @@ class Type_Base {
11 var $seconds; 11 var $seconds;
12 var $data_sources = array('value'); 12 var $data_sources = array('value');
13 var $order; 13 var $order;
14 var $ds_names; 14 var $legend;
15 var $colors; 15 var $colors;
16 var $rrd_title; 16 var $rrd_title;
17 var $rrd_vertical; 17 var $rrd_vertical;
@@ -281,26 +281,26 @@ class Type_Base {
281 $sources = $this->data_sources; 281 $sources = $this->data_sources;
282 } 282 }
283 } 283 }
284 $this->parse_ds_names($sources); 284 $this->parse_legend($sources);
285 return $sources; 285 return $sources;
286 } 286 }
287 287
288 function parse_ds_names($sources) { 288 function parse_legend($sources) {
289 # fill ds_names if not defined by plugin 289 # fill legend if not defined by plugin
290 if (!is_array($this->ds_names)) 290 if (!is_array($this->legend))
291 $this->ds_names = array_combine($sources, $sources); 291 $this->legend = array_combine($sources, $sources);
292 292
293 # detect length of longest ds_name 293 # detect length of longest legend
294 $max = 0; 294 $max = 0;
295 foreach ($this->ds_names as $ds_name) { 295 foreach ($this->legend as $legend) {
296 if(strlen((string)$ds_name) > $max) 296 if(strlen((string)$legend) > $max)
297 $max = strlen((string)$ds_name); 297 $max = strlen((string)$legend);
298 } 298 }
299 299
300 # make all ds_names equal in lenght 300 # make all legend equal in lenght
301 $format = sprintf("%%-%ds", $max); 301 $format = sprintf("%%-%ds", $max);
302 foreach ($this->ds_names as $index => $value) { 302 foreach ($this->legend as $index => $value) {
303 $this->ds_names[$index] = sprintf($format, $value); 303 $this->legend[$index] = sprintf($format, $value);
304 } 304 }
305 } 305 }
306 306
diff --git a/type/Default.class.php b/type/Default.class.php
index 52827c2..9f3b97a 100644
--- a/type/Default.class.php
+++ b/type/Default.class.php
@@ -47,9 +47,9 @@ class Type_Default extends Type_Base {
47 47
48 $c = 0; 48 $c = 0;
49 foreach ($sources as $source) { 49 foreach ($sources as $source) {
50 $dsname = empty($this->ds_names[$source]) ? $source : $this->ds_names[$source]; 50 $legend = empty($this->legend[$source]) ? $source : $this->legend[$source];
51 $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]): $this->colors; 51 $color = is_array($this->colors) ? (isset($this->colors[$source])?$this->colors[$source]:$this->colors[$c++]): $this->colors;
52 $rrdgraph[] = sprintf('"LINE1:avg_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($dsname)); 52 $rrdgraph[] = sprintf('"LINE1:avg_%s#%s:%s"', crc32hex($source), $this->validate_color($color), $this->rrd_escape($legend));
53 $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format); 53 $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format);
54 $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format); 54 $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format);
55 $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format); 55 $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format);
diff --git a/type/GenericIO.class.php b/type/GenericIO.class.php
index df3a057..fac7034 100644
--- a/type/GenericIO.class.php
+++ b/type/GenericIO.class.php
@@ -56,8 +56,8 @@ class Type_GenericIO extends Type_Base {
56 56
57 $i = 0; 57 $i = 0;
58 foreach($sources as $source) { 58 foreach($sources as $source) {
59 $dsname = empty($this->ds_names[$source]) ? $source : $this->ds_names[$source]; 59 $legend = empty($this->legend[$source]) ? $source : $this->legend[$source];
60 $rrdgraph[] = sprintf('"LINE1:avg_%s%s#%s:%s"', crc32hex($source), $i == 1 ? '_neg' : '', $this->colors[$source], $this->rrd_escape($dsname)); 60 $rrdgraph[] = sprintf('"LINE1:avg_%s%s#%s:%s"', crc32hex($source), $i == 1 ? '_neg' : '', $this->colors[$source], $this->rrd_escape($legend));
61 $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format); 61 $rrdgraph[] = sprintf('"GPRINT:min_%s:MIN:%s Min,"', crc32hex($source), $this->rrd_format);
62 $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format); 62 $rrdgraph[] = sprintf('"GPRINT:avg_%s:AVERAGE:%s Avg,"', crc32hex($source), $this->rrd_format);
63 $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format); 63 $rrdgraph[] = sprintf('"GPRINT:max_%s:MAX:%s Max,"', crc32hex($source), $this->rrd_format);
diff --git a/type/GenericStacked.class.php b/type/GenericStacked.class.php
index 4a08c91..a74ff18 100644
--- a/type/GenericStacked.class.php
+++ b/type/GenericStacked.class.php
@@ -49,9 +49,9 @@ class Type_GenericStacked extends Type_Base {
49 49
50 $c = 0; 50 $c = 0;
51 foreach ($sources as $source) { 51 foreach ($sources as $source) {
52 $dsname = empty($this->ds_names[$source]) ? $source : $this->ds_names[$source]; 52 $legend = empty($this->legend[$source]) ? $source : $this->legend[$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($legend));
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);
diff --git a/type/Uptime.class.php b/type/Uptime.class.php
index 3f8a01e..e57df0b 100644
--- a/type/Uptime.class.php
+++ b/type/Uptime.class.php
@@ -41,11 +41,11 @@ class Type_Uptime extends Type_Base {
41 41
42 $c = 0; 42 $c = 0;
43 foreach ($sources as $source) { 43 foreach ($sources as $source) {
44 $dsname = empty($this->ds_names[$source]) ? $source : $this->ds_names[$source]; 44 $legend = empty($this->legend[$source]) ? $source : $this->legend[$source];
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($legend));
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