Completed
Pull Request — develop (#184)
by Tony
23:35
created

Device_ucd_memory::buildRRDGraphParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * BaseGraph.php
4
 *
5
 * This program is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
 *
18
 * @package    LibreNMS
19
 * @link       http://librenms.org
20
 * @copyright  2016 Neil Lathwood
21
 * @author     Neil Lathwood <[email protected]>
22
 */
23
24
namespace App\Graphs;
25
26
class Device_ucd_memory extends BaseGraph
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
27
{
28
29
    protected function buildRRDGraphParams()
30
    {
31
        //FIXME Add support for PNG Graph
32
        return [
33
            'headers' => '',
34
            'defs' => '',
35
        ];
36
    }
37
38
    protected function buildRRDXport()
39
    {
40
        $rrd_file = rrd_name($this->device, 'ucd_mem');
41
        $headers = ['RAM Used', '-Sh Bu Ca', 'RAM Free', 'Swap Used', 'Shared', 'Buffers', 'Cached'];
42
        $defs = "DEF:atotalswap=$rrd_file:totalswap:AVERAGE \
43
                 DEF:aavailswap=$rrd_file:availswap:AVERAGE \
44
                 DEF:atotalreal=$rrd_file:totalreal:AVERAGE \
45
                 DEF:aavailreal=$rrd_file:availreal:AVERAGE \
46
                 DEF:atotalfree=$rrd_file:totalfree:AVERAGE \
47
                 DEF:ashared=$rrd_file:shared:AVERAGE \
48
                 DEF:abuffered=$rrd_file:buffered:AVERAGE \
49
                 DEF:acached=$rrd_file:cached:AVERAGE \
50
                 CDEF:totalswap=atotalswap,1024,* \
51
                 CDEF:availswap=aavailswap,1024,* \
52
                 CDEF:totalreal=atotalreal,1024,* \
53
                 CDEF:availreal=aavailreal,1024,* \
54
                 CDEF:totalfree=atotalfree,1024,* \
55
                 CDEF:shared=ashared,1024,* \
56
                 CDEF:buffered=abuffered,1024,* \
57
                 CDEF:cached=acached,1024,* \
58
                 CDEF:usedreal=totalreal,availreal,- \
59
                 CDEF:usedswap=totalswap,availswap,- \
60
                 CDEF:trueused=usedreal,cached,buffered,shared,-,-,- \
61
                 CDEF:true_perc=trueused,totalreal,/,100,* \
62
                 CDEF:swrl_perc=usedswap,totalreal,/,100,* \
63
                 CDEF:swap_perc=usedswap,totalswap,/,100,* \
64
                 CDEF:real_perc=usedreal,totalreal,/,100,* \
65
                 CDEF:real_percf=100,real_perc,- \
66
                 CDEF:shared_perc=shared,totalreal,/,100,* \
67
                 CDEF:buffered_perc=buffered,totalreal,/,100,* \
68
                 CDEF:cached_perc=cached,totalreal,/,100,* \
69
                 CDEF:cusedswap=usedswap,-1,* \
70
                 CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+ \
71
                 XPORT:usedreal:'Ram Used' \
72
                 XPORT:trueused:'-Sh, Bu, Ca' \
73
                 XPORT:availreal:'RAM Free' \
74
                 XPORT:usedswap:'Swap Used' \
75
                 XPORT:shared:'Shared' \
76
                 XPORT:buffered:'Buffers' \
77
                 XPORT:cached:'Cached'";
78
        return [
79
            'headers' => $headers,
80
            'defs' => $defs,
81
        ];
82
    }
83
}
84