diff options
Diffstat (limited to 'type/GenericIO.class.php')
-rw-r--r-- | type/GenericIO.class.php | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/type/GenericIO.class.php b/type/GenericIO.class.php new file mode 100644 index 0000000..573abde --- /dev/null +++ b/type/GenericIO.class.php | |||
@@ -0,0 +1,59 @@ | |||
1 | <?php | ||
2 | |||
3 | require_once 'Default.class.php'; | ||
4 | |||
5 | class Type_GenericIO extends Type_Default { | ||
6 | |||
7 | function rrd_gen_graph() { | ||
8 | $filename = $this->get_filename(); | ||
9 | |||
10 | $rrdgraph[] = '/usr/bin/rrdtool graph - -a PNG'; | ||
11 | $rrdgraph[] = sprintf('-w %d', is_numeric($this->width) ? $this->width : 400); | ||
12 | $rrdgraph[] = sprintf('-h %d', is_numeric($this->heigth) ? $this->heigth : 175); | ||
13 | $rrdgraph[] = '-l 0'; | ||
14 | $rrdgraph[] = sprintf('-t "%s"', $this->rrd_title); | ||
15 | $rrdgraph[] = sprintf('-v "%s"', $this->rrd_vertical); | ||
16 | $rrdgraph[] = sprintf('-s -%d', is_numeric($this->seconds) ? $this->seconds : 86400); | ||
17 | |||
18 | if ($this->scale) | ||
19 | $raw = '_raw'; | ||
20 | foreach($this->data_sources as $ds) { | ||
21 | $rrdgraph[] = sprintf('DEF:min_%s%s=%s:%s:MIN', $ds, $raw, $filename, $ds); | ||
22 | $rrdgraph[] = sprintf('DEF:avg_%s%s=%s:%s:AVERAGE', $ds, $raw, $filename, $ds); | ||
23 | $rrdgraph[] = sprintf('DEF:max_%s%s=%s:%s:MAX', $ds, $raw, $filename, $ds); | ||
24 | } | ||
25 | if ($this->scale) { | ||
26 | foreach($this->data_sources as $ds) { | ||
27 | $rrdgraph[] = sprintf('CDEF:min_%s=min_%s_raw,%s,*', $ds, $ds, $this->scale); | ||
28 | $rrdgraph[] = sprintf('CDEF:avg_%s=avg_%s_raw,%s,*', $ds, $ds, $this->scale); | ||
29 | $rrdgraph[] = sprintf('CDEF:max_%s=max_%s_raw,%s,*', $ds, $ds, $this->scale); | ||
30 | } | ||
31 | } | ||
32 | |||
33 | $rrdgraph[] = sprintf('CDEF:overlap=avg_%s,avg_%s,LT,avg_%1$s,avg_%2$s,IF', | ||
34 | $this->data_sources[0], $this->data_sources[1]); | ||
35 | |||
36 | foreach($this->data_sources as $ds) { | ||
37 | $rrdgraph[] = sprintf('AREA:avg_%s#%s', $ds, $this->get_faded_color($this->colors[$ds])); | ||
38 | } | ||
39 | |||
40 | $rrdgraph[] = sprintf('AREA:overlap#%s', | ||
41 | $this->get_faded_color( | ||
42 | $this->get_faded_color($this->colors[$this->data_sources[0]]), | ||
43 | $this->get_faded_color($this->colors[$this->data_sources[1]]) | ||
44 | ) | ||
45 | ); | ||
46 | |||
47 | foreach($this->data_sources as $ds) { | ||
48 | $rrdgraph[] = sprintf('LINE1:avg_%s#%s:\'%s\'', $ds, $this->colors[$ds], $this->ds_names[$ds]); | ||
49 | $rrdgraph[] = sprintf('GPRINT:min_%s:MIN:\'%s Min,\'', $ds, $this->rrd_format); | ||
50 | $rrdgraph[] = sprintf('GPRINT:avg_%s:AVERAGE:\'%s Avg,\'', $ds, $this->rrd_format); | ||
51 | $rrdgraph[] = sprintf('GPRINT:max_%s:MAX:\'%s Max,\'', $ds, $this->rrd_format); | ||
52 | $rrdgraph[] = sprintf('GPRINT:avg_%s:LAST:\'%s Last\l\'', $ds, $this->rrd_format); | ||
53 | } | ||
54 | |||
55 | return $rrdgraph; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | ?> | ||