forked from lausser/check_nwc_health
-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_nwc_health.php
58 lines (51 loc) · 2.4 KB
/
check_nwc_health.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
53
54
55
56
57
58
<?php
#
# This is a template for the visualisation addon PNP (http://www.pnp4nagios.org)
#
# Plugin: check_nwc_health - https://labs.consol.de/nagios/check_nwc_health/
# Release 1.0 2013-07-18
#
$def[1] = "";
$opt[1] = "";
$_WARNRULE = '#FFFF00';
$_CRITRULE = '#FF0000';
$num = 1;
foreach ($DS as $i=>$VAL) {
# eth0_usage_in / out
if(preg_match('/^(.*?)_usage_in/', $NAME[$i])) {
$interface = preg_replace('/_.*$/', '', $NAME[$i]);
$ds_name[$num] = $interface.' usage';
$opt[$num] = "--vertical-label \"Usage\" -l 0 -u 100 --title \"Interface Usage for $hostname - ".$interface."\" ";
$def[$num] = "DEF:percin=$RRDFILE[$i]:$DS[$i]:AVERAGE ";
$def[$num] .= "DEF:percout=".$RRDFILE[$i+1].":".$DS[$i+1].":AVERAGE ";
$def[$num] .= "LINE2:percin#00e060:\"in\t\" ";
$def[$num] .= "GPRINT:percin:LAST:\"%10.1lf %% last\" ";
$def[$num] .= "GPRINT:percin:AVERAGE:\"%7.1lf %% avg\" ";
$def[$num] .= "GPRINT:percin:MAX:\"%7.1lf %% max\\n\" ";
$def[$num] .= "LINE2:percout#0080e0:\"out\t\" ";
$def[$num] .= "GPRINT:percout:LAST:\"%10.1lf %% last\" ";
$def[$num] .= "GPRINT:percout:AVERAGE:\"%7.1lf %% avg\" ";
$def[$num] .= "GPRINT:percout:MAX:\"%7.1lf %% max\"\\n ";
$def[$num] .= "HRULE:$WARN[$num]$_WARNRULE ";
$def[$num] .= "HRULE:$CRIT[$num]$_CRITRULE ";
$num++;
}
# eth0_traffic_in / out
if(preg_match('/^(.*?)_traffic_in/', $NAME[$i])) {
$interface = preg_replace('/_.*$/', '', $NAME[$i]);
$ds_name[$num] = $interface.' traffic';
$opt[$num] = "--vertical-label \"Traffic\" -b 1024 --title \"Interface Traffic for $hostname - $interface\" ";
$def[$num] = "DEF:bitsin=$RRDFILE[$i]:$DS[$i]:AVERAGE ";
$def[$num] .= "DEF:bitsout=".$RRDFILE[$i+1].":".$DS[$i+1].":AVERAGE ";
$def[$num] .= "AREA:bitsin#00e060:\"in\t\" ";
$def[$num] .= "GPRINT:bitsin:LAST:\"%10.1lf %Sb/s last\" ";
$def[$num] .= "GPRINT:bitsin:AVERAGE:\"%7.1lf %Sb/s avg\" ";
$def[$num] .= "GPRINT:bitsin:MAX:\"%7.1lf %Sb/s max\\n\" ";
$def[$num] .= "CDEF:bitsminusout=0,bitsout,- ";
$def[$num] .= "AREA:bitsminusout#0080e0:\"out\t\" ";
$def[$num] .= "GPRINT:bitsout:LAST:\"%10.1lf %Sb/s last\" ";
$def[$num] .= "GPRINT:bitsout:AVERAGE:\"%7.1lf %Sb/s avg\" ";
$def[$num] .= "GPRINT:bitsout:MAX:\"%7.1lf %Sb/s max\\n\" ";
}
}
?>