diff options
Diffstat (limited to 'type/GenericIO.class.php')
-rw-r--r-- | type/GenericIO.class.php | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/type/GenericIO.class.php b/type/GenericIO.class.php index e91cb16..ee04316 100644 --- a/type/GenericIO.class.php +++ b/type/GenericIO.class.php | |||
@@ -5,45 +5,54 @@ require_once 'Default.class.php'; | |||
5 | class Type_GenericIO extends Type_Default { | 5 | class Type_GenericIO extends Type_Default { |
6 | 6 | ||
7 | function rrd_gen_graph() { | 7 | function rrd_gen_graph() { |
8 | $filename = $this->get_filename(); | ||
9 | |||
10 | $rrdgraph = $this->rrd_options(); | 8 | $rrdgraph = $this->rrd_options(); |
11 | 9 | ||
10 | $sources = $this->rrd_get_sources(); | ||
11 | |||
12 | if ($this->scale) | 12 | if ($this->scale) |
13 | $raw = '_raw'; | 13 | $raw = '_raw'; |
14 | foreach($this->data_sources as $ds) { | 14 | $i=0; |
15 | $rrdgraph[] = sprintf('DEF:min_%s%s=%s:%s:MIN', $ds, $raw, $filename, $ds); | 15 | foreach ($this->tinstances as $tinstance) { |
16 | $rrdgraph[] = sprintf('DEF:avg_%s%s=%s:%s:AVERAGE', $ds, $raw, $filename, $ds); | 16 | foreach ($this->data_sources as $ds) { |
17 | $rrdgraph[] = sprintf('DEF:max_%s%s=%s:%s:MAX', $ds, $raw, $filename, $ds); | 17 | $rrdgraph[] = sprintf('DEF:min_%s%s=%s:%s:MIN', $sources[$i], $raw, $this->files[$tinstance], $ds); |
18 | $rrdgraph[] = sprintf('DEF:avg_%s%s=%s:%s:AVERAGE', $sources[$i], $raw, $this->files[$tinstance], $ds); | ||
19 | $rrdgraph[] = sprintf('DEF:max_%s%s=%s:%s:MAX', $sources[$i], $raw, $this->files[$tinstance], $ds); | ||
20 | $i++; | ||
21 | } | ||
18 | } | 22 | } |
19 | if ($this->scale) { | 23 | if ($this->scale) { |
20 | foreach($this->data_sources as $ds) { | 24 | $i=0; |
21 | $rrdgraph[] = sprintf('CDEF:min_%s=min_%s_raw,%s,*', $ds, $ds, $this->scale); | 25 | foreach ($this->tinstances as $tinstance) { |
22 | $rrdgraph[] = sprintf('CDEF:avg_%s=avg_%s_raw,%s,*', $ds, $ds, $this->scale); | 26 | foreach ($this->data_sources as $ds) { |
23 | $rrdgraph[] = sprintf('CDEF:max_%s=max_%s_raw,%s,*', $ds, $ds, $this->scale); | 27 | $rrdgraph[] = sprintf('CDEF:min_%s=min_%1$s_raw,%s,*', $sources[$i], $this->scale); |
28 | $rrdgraph[] = sprintf('CDEF:avg_%s=avg_%1$s_raw,%s,*', $sources[$i], $this->scale); | ||
29 | $rrdgraph[] = sprintf('CDEF:max_%s=max_%1$s_raw,%s,*', $sources[$i], $this->scale); | ||
30 | $i++; | ||
31 | } | ||
24 | } | 32 | } |
25 | } | 33 | } |
26 | 34 | ||
27 | $rrdgraph[] = sprintf('CDEF:overlap=avg_%s,avg_%s,LT,avg_%1$s,avg_%2$s,IF', | 35 | $rrdgraph[] = sprintf('CDEF:overlap=avg_%s,avg_%s,LT,avg_%1$s,avg_%2$s,IF', |
28 | $this->data_sources[0], $this->data_sources[1]); | 36 | $sources[0], $sources[1]); |
29 | 37 | ||
30 | foreach($this->data_sources as $ds) { | 38 | foreach($sources as $source) { |
31 | $rrdgraph[] = sprintf('AREA:avg_%s#%s', $ds, $this->get_faded_color($this->colors[$ds])); | 39 | $rrdgraph[] = sprintf('AREA:avg_%s#%s', $source, $this->get_faded_color($this->colors[$source])); |
32 | } | 40 | } |
33 | 41 | ||
34 | $rrdgraph[] = sprintf('AREA:overlap#%s', | 42 | $rrdgraph[] = sprintf('AREA:overlap#%s', |
35 | $this->get_faded_color( | 43 | $this->get_faded_color( |
36 | $this->get_faded_color($this->colors[$this->data_sources[0]]), | 44 | $this->get_faded_color($this->colors[$sources[0]]), |
37 | $this->get_faded_color($this->colors[$this->data_sources[1]]) | 45 | $this->get_faded_color($this->colors[$sources[1]]) |
38 | ) | 46 | ) |
39 | ); | 47 | ); |
40 | 48 | ||
41 | foreach($this->data_sources as $ds) { | 49 | foreach($sources as $source) { |
42 | $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', $ds, $this->colors[$ds], $this->ds_names[$ds]); | 50 | $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source; |
43 | $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', $ds, $this->rrd_format); | 51 | $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', $source, $this->colors[$source], $dsname); |
44 | $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', $ds, $this->rrd_format); | 52 | $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', $source, $this->rrd_format); |
45 | $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', $ds, $this->rrd_format); | 53 | $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', $source, $this->rrd_format); |
46 | $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\l\'', $ds, $this->rrd_format); | 54 | $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', $source, $this->rrd_format); |
55 | $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\l\'', $source, $this->rrd_format); | ||
47 | } | 56 | } |
48 | 57 | ||
49 | return $rrdgraph; | 58 | return $rrdgraph; |