Completed
Pull Request — develop (#184)
by Tony
32:16
created

Device_ucd_memory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getHeaders() 0 4 1
A getRRDGraphDefinition() 0 4 1
B getRRDXportDefinition() 0 41 1
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
use App\Data\RRD;
27
28
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...
29
{
30
    protected function getHeaders()
31
    {
32
        return ['RAM Used', '-Sh Bu Ca', 'RAM Free', 'Swap Used', 'Shared', 'Buffers', 'Cached'];
33
    }
34
35
    protected function getRRDGraphDefinition()
36
    {
37
        // TODO: Implement getRRDGraphDefinition() method.
38
    }
39
40
    protected function getRRDXportDefinition()
41
    {
42
        $rrd_file = RRD::getFileName($this->device, 'ucd_mem');
43
        $defs = "DEF:atotalswap=$rrd_file:totalswap:AVERAGE \
44
                 DEF:aavailswap=$rrd_file:availswap:AVERAGE \
45
                 DEF:atotalreal=$rrd_file:totalreal:AVERAGE \
46
                 DEF:aavailreal=$rrd_file:availreal:AVERAGE \
47
                 DEF:atotalfree=$rrd_file:totalfree:AVERAGE \
48
                 DEF:ashared=$rrd_file:shared:AVERAGE \
49
                 DEF:abuffered=$rrd_file:buffered:AVERAGE \
50
                 DEF:acached=$rrd_file:cached:AVERAGE \
51
                 CDEF:totalswap=atotalswap,1024,* \
52
                 CDEF:availswap=aavailswap,1024,* \
53
                 CDEF:totalreal=atotalreal,1024,* \
54
                 CDEF:availreal=aavailreal,1024,* \
55
                 CDEF:totalfree=atotalfree,1024,* \
56
                 CDEF:shared=ashared,1024,* \
57
                 CDEF:buffered=abuffered,1024,* \
58
                 CDEF:cached=acached,1024,* \
59
                 CDEF:usedreal=totalreal,availreal,- \
60
                 CDEF:usedswap=totalswap,availswap,- \
61
                 CDEF:trueused=usedreal,cached,buffered,shared,-,-,- \
62
                 CDEF:true_perc=trueused,totalreal,/,100,* \
63
                 CDEF:swrl_perc=usedswap,totalreal,/,100,* \
64
                 CDEF:swap_perc=usedswap,totalswap,/,100,* \
65
                 CDEF:real_perc=usedreal,totalreal,/,100,* \
66
                 CDEF:real_percf=100,real_perc,- \
67
                 CDEF:shared_perc=shared,totalreal,/,100,* \
68
                 CDEF:buffered_perc=buffered,totalreal,/,100,* \
69
                 CDEF:cached_perc=cached,totalreal,/,100,* \
70
                 CDEF:cusedswap=usedswap,-1,* \
71
                 CDEF:cdeftot=availreal,shared,buffered,usedreal,cached,usedswap,+,+,+,+,+ \
72
                 XPORT:usedreal:'Ram Used' \
73
                 XPORT:trueused:'-Sh, Bu, Ca' \
74
                 XPORT:availreal:'RAM Free' \
75
                 XPORT:usedswap:'Swap Used' \
76
                 XPORT:shared:'Shared' \
77
                 XPORT:buffered:'Buffers' \
78
                 XPORT:cached:'Cached'";
79
        return $defs;
80
    }
81
}
82