Completed
Push — master ( 7d9761...77615c )
by Tony
02:53
created

RRDGraph::fetch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * RRDGraph.php
4
 *
5
 * -Description-
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 * @package    LibreNMS
21
 * @link       http://librenms.org
22
 * @copyright  2016 Tony Murray
23
 * @author     Tony Murray <[email protected]>
24
 */
25
26
namespace App\Data;
27
28
class RRDGraph extends RRD
29
{
30
    protected $supported_formats = ['png'];
31
32
    public function __construct($definitions, $start, $end, $width, $height)
33
    {
34
        $args = " graph - -s $start -e $end  --width $width --height $height ".
35
            "--alt-autoscale-max --rigid -E -c BACK#EEEEEE00 -c SHADEA#EEEEEE00 -c SHADEB#EEEEEE00 -c \
36
            FONT#000000 -c CANVAS#FFFFFF00 -c GRID#a5a5a5 -c MGRID#FF9999 -c FRAME#5e5e5e -c ARROW#5e5e5e \
37
            -R normal --font LEGEND:8:DejaVuSansMono --font AXIS:7:DejaVuSansMono --font-render-mode normal ".
38
            $definitions;
39
40
        parent::__construct($args);
41
    }
42
43
    /**
44
     * Return the output from this data source
45
     * May be base64 encoded PNG, Json Data, or CSV Data
46
     *
47
     * @param string $format png, json, or csv
48
     * @return string
49
     */
50
    public function fetch($format)
51
    {
52
        $this->checkFormatSupported($format);
53
        return base64_encode($this->run());
54
    }
55
}
56