Test Failed
Push — develop ( 55b248...7d9761 )
by Tony
21:25
created

Memory::getRRDGraphDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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