diff options
Diffstat (limited to 'type/GenericStacked.class.php')
-rw-r--r-- | type/GenericStacked.class.php | 59 |
1 files changed, 22 insertions, 37 deletions
diff --git a/type/GenericStacked.class.php b/type/GenericStacked.class.php index f024336..7595385 100644 --- a/type/GenericStacked.class.php +++ b/type/GenericStacked.class.php | |||
@@ -3,56 +3,41 @@ | |||
3 | require_once 'Default.class.php'; | 3 | require_once 'Default.class.php'; |
4 | 4 | ||
5 | class Type_GenericStacked extends Type_Default { | 5 | class Type_GenericStacked extends Type_Default { |
6 | 6 | ||
7 | function rrd_gen_graph() { | 7 | function rrd_gen_graph() { |
8 | $rrdgraph = $this->rrd_options(); | 8 | $rrdgraph = $this->rrd_options(); |
9 | 9 | ||
10 | if (is_array($this->args['tinstance'])) | 10 | $sources = $this->rrd_get_sources(); |
11 | if (is_array($this->order)) | ||
12 | $array = array_intersect($this->order, $this->args['tinstance']); | ||
13 | else | ||
14 | $array = $this->args['tinstance']; | ||
15 | else | ||
16 | $array = $this->data_sources; | ||
17 | 11 | ||
18 | $i=0; | 12 | $i=0; |
19 | foreach ($array as $value) { | 13 | foreach ($this->tinstances as $tinstance) { |
20 | if (is_array($this->args['tinstance'])) { | 14 | foreach ($this->data_sources as $ds) { |
21 | $filename = $this->get_filename($value); | 15 | $rrdgraph[] = sprintf('DEF:min_%s=%s:%s:MIN', $sources[$i], $this->files[$tinstance], $ds); |
22 | $ds = $this->data_sources[0]; | 16 | $rrdgraph[] = sprintf('DEF:avg_%s=%s:%s:AVERAGE', $sources[$i], $this->files[$tinstance], $ds); |
23 | } else { | 17 | $rrdgraph[] = sprintf('DEF:max_%s=%s:%s:MAX', $sources[$i], $this->files[$tinstance], $ds); |
24 | $filename = $this->get_filename(); | 18 | $i++; |
25 | $ds = $value; | ||
26 | } | 19 | } |
27 | $rrdgraph[] = sprintf('DEF:min%s=%s:%s:MIN', $i, $filename, $ds); | ||
28 | $rrdgraph[] = sprintf('DEF:avg%s=%s:%s:AVERAGE', $i, $filename, $ds); | ||
29 | $rrdgraph[] = sprintf('DEF:max%s=%s:%s:MAX', $i, $filename, $ds); | ||
30 | $i++; | ||
31 | } | 20 | } |
32 | 21 | ||
33 | for ($i=count($array)-1 ; $i>=0 ; $i--) { | 22 | for ($i=count($sources)-1 ; $i>=0 ; $i--) { |
34 | if ($i == (count($array)-1)) | 23 | if ($i == (count($sources)-1)) |
35 | $rrdgraph[] = sprintf('CDEF:cdef%d=avg%d', $i, $i); | 24 | $rrdgraph[] = sprintf('CDEF:area_%s=avg_%1$s', $sources[$i]); |
36 | else | 25 | else |
37 | $rrdgraph[] = sprintf('CDEF:cdef%d=cdef%d,avg%d,+', $i, $i+1, $i); | 26 | $rrdgraph[] = sprintf('CDEF:area_%s=area_%s,avg_%1$s,+', $sources[$i], $sources[$i+1]); |
38 | } | 27 | } |
39 | 28 | ||
40 | $i=0; | 29 | foreach ($sources as $source) { |
41 | foreach ($array as $value) { | 30 | $color = $this->get_faded_color($this->colors[$source]); |
42 | $color = $this->get_faded_color($this->colors[$value]); | 31 | $rrdgraph[] = sprintf('AREA:area_%s#%s', $source, $color); |
43 | $rrdgraph[] = sprintf('AREA:cdef%d#%s', $i, $color); | ||
44 | $i++; | ||
45 | } | 32 | } |
46 | 33 | ||
47 | $i=0; | 34 | foreach ($sources as $source) { |
48 | foreach ($array as $value) { | 35 | $dsname = $this->ds_names[$source] != '' ? $this->ds_names[$source] : $source; |
49 | $dsname = $this->ds_names[$value] != '' ? $this->ds_names[$value] : $value; | 36 | $rrdgraph[] = sprintf('LINE1:area_%s#%s:\'%s\'', $source, $this->validate_color($this->colors[$source]), $dsname); |
50 | $rrdgraph[] = sprintf('LINE1:cdef%d#%s:\'%s\'', $i, $this->validate_color($this->colors[$value]), $dsname); | 37 | $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', $source, $this->rrd_format); |
51 | $rrdgraph[] = sprintf('GPRINT:min%d:MIN:\'%s Min,\'', $i, $this->rrd_format); | 38 | $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', $source, $this->rrd_format); |
52 | $rrdgraph[] = sprintf('GPRINT:avg%d:AVERAGE:\'%s Avg,\'', $i, $this->rrd_format); | 39 | $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', $source, $this->rrd_format); |
53 | $rrdgraph[] = sprintf('GPRINT:max%d:MAX:\'%s Max,\'', $i, $this->rrd_format); | 40 | $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\\l\'', $source, $this->rrd_format); |
54 | $rrdgraph[] = sprintf('GPRINT:avg%d:LAST:\'%s Last\\l\'', $i, $this->rrd_format); | ||
55 | $i++; | ||
56 | } | 41 | } |
57 | 42 | ||
58 | return $rrdgraph; | 43 | return $rrdgraph; |