-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcheck_iftraffic_nrpe.sh.php
60 lines (44 loc) · 1.62 KB
/
check_iftraffic_nrpe.sh.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
59
60
<?php
#
#
# Define some colors
$red = '#FF0000';
$magenta = '#FF00FF';
$navy = '#000080';
$green = '#008000';
$yellow = '#FFFF00';
$orangered = '#FF4500';
$darkred = '#8B0000';
$blue = '#0000FF';
$darkblue = '#000099';
$darkorange = '#FF8C00';
$line[1] = $navy;
$line[2] = $orangered;
$counter = 1;
$servicedesc = str_replace("_", " ", $servicedesc);
# Main logic
foreach ($DS as $i)
{
$maxcounter = $i;
}
for ($loopcounter = 1; $loopcounter < $maxcounter; $loopcounter++)
{
$interface = $NAME[$loopcounter];
#$interface = ereg_replace("_.*$", "", $interface);
$interface = preg_replace("/^.*-/", "", $interface);
$ds_name[$counter] = $interface;
$opt[$counter] = " --vertical-label \"Traffic\" -b 1000 --title \"Interface Traffic for $hostname / $servicedesc\" ";
$def[$counter] = "DEF:inbound=$RRDFILE[$loopcounter]:$DS[$loopcounter]:AVERAGE " ;
$loopcounter++;
$def[$counter] .= "DEF:outbound=$RRDFILE[$loopcounter]:$DS[$loopcounter]:AVERAGE " ;
$def[$counter] .= "LINE1:inbound$line[1]:\"in \" " ;
$def[$counter] .= "GPRINT:inbound:LAST:\"%7.2lf %SB/s last\" " ;
$def[$counter] .= "GPRINT:inbound:AVERAGE:\"%7.2lf %SB/s avg\" " ;
$def[$counter] .= "GPRINT:inbound:MAX:\"%7.2lf %SB/s max\\n\" " ;
$def[$counter] .= "LINE1:outbound$line[2]:\"out \" " ;
$def[$counter] .= "GPRINT:outbound:LAST:\"%7.2lf %SB/s last\" " ;
$def[$counter] .= "GPRINT:outbound:AVERAGE:\"%7.2lf %SB/s avg\" " ;
$def[$counter] .= "GPRINT:outbound:MAX:\"%7.2lf %SB/s max\\n\" ";
$counter++;
}
?>