-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcheck_mem.php
52 lines (40 loc) · 1.84 KB
/
check_mem.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
$ds_name[1] = "sysinfo";
$opt[1] = "--vertical-label \"Bytes\" -l0 --title \"Memory usage for $hostname / $servicedesc\" ";
# Total Memory
$def[1] = "DEF:mem_total=$RRDFILE[1]:$DS[1]:AVERAGE " ;
# Used Memory
$def[1] .= "DEF:mem_used=$RRDFILE[1]:$DS[2]:AVERAGE " ;
# Cache
$def[1] .= "DEF:mem_cache=$RRDFILE[1]:$DS[3]:AVERAGE " ;
# Buffer
$def[1] .= "DEF:mem_buffer=$RRDFILE[1]:$DS[4]:AVERAGE " ;
# Memory Cache
$def[1] .= rrd::cdef("mem_cache_tmp", "mem_cache,mem_buffer,+,mem_used,+");
$def[1] .= rrd::area("mem_cache_tmp", "#DCDDD5", "Disk Cache");
$def[1] .= "GPRINT:mem_cache:LAST:\"%3.2lf %sB Last \" ";
$def[1] .= "GPRINT:mem_cache:MAX:\"%3.2lf %sB Max \" ";
$def[1] .= "GPRINT:mem_cache" . ':AVERAGE:"%3.2lf %sB Average \j" ';
# Memory Buffer
$def[1] .= rrd::cdef("mem_buffer_tmp", "mem_buffer,mem_used,+");
$def[1] .= rrd::area("mem_buffer_tmp", "#3E606F", "I/O Buffers");
$def[1] .= "GPRINT:mem_buffer:LAST:\"%3.2lf %sB Last \" ";
$def[1] .= "GPRINT:mem_buffer:MAX:\"%3.2lf %sB Max \" ";
$def[1] .= "GPRINT:mem_buffer" . ':AVERAGE:"%3.2lf %sB Average \j" ';
# Memory Used
$def[1] .= rrd::area("mem_used", "#193441", "Processes");
$def[1] .= "GPRINT:mem_used:LAST:\"%3.2lf %sB Last \" ";
$def[1] .= "GPRINT:mem_used:MAX:\"%3.2lf %sB Max \" ";
$def[1] .= "GPRINT:mem_used" . ':AVERAGE:"%3.2lf %sB Average \j" ';
# Memory Total
$def[1] .= rrd::line1("mem_total", "#000000", "Total");
$def[1] .= "GPRINT:mem_total:LAST:\"%3.2lf %sB Last \" ";
$def[1] .= "GPRINT:mem_total:MAX:\"%3.2lf %sB Max \" ";
$def[1] .= "GPRINT:mem_total" . ':AVERAGE:"%3.2lf %sB Average \j" ';
if ($WARN[2] != "") {
$def[1] .= "HRULE:$WARN[2]#ffff00:\"Warning threshold for Processes\j\" ";
}
if ($CRIT[2] != "") {
$def[1] .= "HRULE:$CRIT[2]#ff0000:\"Critical threshold for Processes\" ";
}
?>