diff options
Diffstat (limited to 'type/GenericStacked.class.php')
| -rw-r--r-- | type/GenericStacked.class.php | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/type/GenericStacked.class.php b/type/GenericStacked.class.php new file mode 100644 index 0000000..99f05eb --- /dev/null +++ b/type/GenericStacked.class.php | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | require_once 'Default.class.php'; | ||
| 4 | |||
| 5 | class Type_GenericStacked extends Type_Default { | ||
| 6 | |||
| 7 | function rrd_gen_graph() { | ||
| 8 | $rrdgraph[] = '/usr/bin/rrdtool graph - -a PNG'; | ||
| 9 | $rrdgraph[] = sprintf('-w %d', is_numeric($this->width) ? $this->width : 400); | ||
| 10 | $rrdgraph[] = sprintf('-h %d', is_numeric($this->heigth) ? $this->heigth : 175); | ||
| 11 | $rrdgraph[] = '-l 0'; | ||
| 12 | $rrdgraph[] = sprintf('-t "%s"', $this->rrd_title); | ||
| 13 | $rrdgraph[] = sprintf('-v "%s"', $this->rrd_vertical); | ||
| 14 | $rrdgraph[] = sprintf('-s -%d', is_numeric($this->seconds) ? $this->seconds : 86400); | ||
| 15 | |||
| 16 | if (is_array($this->args['tinstance'])) | ||
| 17 | $array = is_array($this->order) ? $this->order : $this->args['tinstance']; | ||
| 18 | else | ||
| 19 | $array = $this->data_sources; | ||
| 20 | |||
| 21 | $i=0; | ||
| 22 | foreach ($array as $value) { | ||
| 23 | if (is_array($this->args['tinstance'])) { | ||
| 24 | $filename = $this->get_filename($value); | ||
| 25 | $ds = $this->data_sources[0]; | ||
| 26 | } else { | ||
| 27 | $filename = $this->get_filename(); | ||
| 28 | $ds = $value; | ||
| 29 | } | ||
| 30 | $rrdgraph[] = sprintf('DEF:min%s=%s:%s:MIN', $i, $filename, $ds); | ||
| 31 | $rrdgraph[] = sprintf('DEF:avg%s=%s:%s:AVERAGE', $i, $filename, $ds); | ||
| 32 | $rrdgraph[] = sprintf('DEF:max%s=%s:%s:MAX', $i, $filename, $ds); | ||
| 33 | $i++; | ||
| 34 | } | ||
| 35 | |||
| 36 | for ($i=count($array)-1 ; $i>=0 ; $i--) { | ||
| 37 | if ($i == (count($array)-1)) | ||
| 38 | $rrdgraph[] = sprintf('CDEF:cdef%d=avg%d', $i, $i); | ||
| 39 | else | ||
| 40 | $rrdgraph[] = sprintf('CDEF:cdef%d=cdef%d,avg%d,+', $i, $i+1, $i); | ||
| 41 | } | ||
| 42 | |||
| 43 | $i=0; | ||
| 44 | foreach ($array as $value) { | ||
| 45 | $color = $this->get_faded_color($this->colors[$value]); | ||
| 46 | $rrdgraph[] = sprintf('AREA:cdef%d#%s', $i, $color); | ||
| 47 | $i++; | ||
| 48 | } | ||
| 49 | |||
| 50 | $i=0; | ||
| 51 | foreach ($array as $value) { | ||
| 52 | $dsname = $this->ds_names[$value] != '' ? $this->ds_names[$value] : $value; | ||
| 53 | $rrdgraph[] = sprintf('LINE1:cdef%d#%s:\'%s\'', $i, $this->validate_color($this->colors[$value]), $dsname); | ||
| 54 | $rrdgraph[] = sprintf('GPRINT:min%d:MIN:\'%s Min,\'', $i, $this->rrd_format); | ||
| 55 | $rrdgraph[] = sprintf('GPRINT:avg%d:AVERAGE:\'%s Avg,\'', $i, $this->rrd_format); | ||
| 56 | $rrdgraph[] = sprintf('GPRINT:max%d:MAX:\'%s Max,\'', $i, $this->rrd_format); | ||
| 57 | $rrdgraph[] = sprintf('GPRINT:avg%d:LAST:\'%s Last\\l\'', $i, $this->rrd_format); | ||
| 58 | $i++; | ||
| 59 | } | ||
| 60 | |||
| 61 | return $rrdgraph; | ||
| 62 | } | ||
| 63 | } | ||
| 64 | |||
| 65 | ?> | ||
