Icinga2 monitors traffic traffic for netapp, ubuntu, and windows
Icinga2 monitors traffic traffic for netapp, ubuntu, and windows
Note: on Grafana, select data rate-- kilobits/sec (displayed as b, except 8 is a large B value)
Download plug-in website: https://github.com/cloved/check_traffic/blob/master/check_traffic.sh
# mv check_traffic.sh / usr/lib64/nagios/plugins/
# chmod + x / usr/lib64/nagios/plugins/check_traffic.sh
# cd / usr/lib64/nagios/plugins/
# cp check_traffic.sh check_traffic_in.sh
# cp check_traffic.sh check_traffic_out.sh
Description: the reason for getting in and out out is for the image to come out later. By default, the script only displays the image of the Interval index, but it is of no use. After giving the image (you need to have the image first), the last part of the script
$Echo "$Msg"-"The Traffic In is" $uIn "${Unit_1} ${Unit_2}, Out is" $uOut "${Unit_1} ${Unit_2}, Total is" $uTotal "${Unit_1} ${Unit_2}. The Check Out is "$Interval" s\ | In\ = ${uIn} ${Unit_1} ${Unit_2}; ${W1}\; ${C1}\; 0\; 0 Interval\ = ${Unit_1} ${Unit_2}\; ${W2}\; ${C2}\; 0 Total\ = ${uTotal} ${Unit_1} ${Unit_2}\; ${Wt}\; ${Ct}\; 0\; 0 Interval\ = ${Interval} s\; 1200; 1800\ 0\; 0
Change to
$Echo "$Msg"-"The Traffic In is" $uIn "${Unit_1} ${Unit_2}, Out is" $uOut "${Unit_1} ${Unit_2}, Total is" $uTotal "${Unit_1} ${Unit_2}. The Check Out is "$Interval" s\ | In\ = ${uIn} ${Unit_1} ${Unit_2}\; ${W1}\; ${C1}\; 0\; 0 Interval\ = ${Unit_1} ${Unit_2}\; ${W2}\; ${C2}\; 0 Total\ = ${uTotal} ${Unit_1} ${Unit_2}\; ${Wt}\; ${Ct}\; 0\ 0 In\ = ${uIn} ${Unit_1} ${Unit_2}\; 1200\; 1800\; 0; 0
It is also suggested to make adjustments to Min_Interval and Max_Interval.
Min_Interval=0 (default is 30s, that is, the second execution can only be done every 30s)
Max_Interval=5800 (default is 1800. Error will be reported if netapp is not modified)
In addition, if you don't want to set warning, crit and other alarms (it doesn't make much sense here, you mainly want the image, you can delete the if statements such as OK, warning, crit and so on in the script)
Use:
Ubuntu:
# / usr/lib64/nagios/plugins/check_traffic_in.sh-V 2c-H 10.0.0.88-C public-N em1-w 1 Ubuntu 50-c 180200 (em1 above eth0,-V refers to the version of snmp)
Netapp:
# / usr/lib64/nagios/plugins/check_traffic.sh-V 2c-H 10.0.1.10-C public-N vif1-w 1Magi 50-c 180200-K-B (vif1 refers to the stored network card,-K-B may not be added)
Windows:
# / usr/lib64/nagios/plugins/check_traffic_in.sh-V 2c-H 172.16.0.3-C public-I 1-w 1pm 50-c 180200 (1 refers to local connection 1)
Example (netapp,ubuntu,windows reference adjustment, eth0, local connection 2, etc., make a separate services.conf entry)
# vi/etc/icinga2/conf.d/templates.conf
Object CheckCommand "nas-traffic-in" {
Import "plugin-check-command"
Command = [PluginDir + "/ check_traffic_in.sh"]
Arguments = {
"- H" = "$address$"
"- C" = "$snmp$"
"- V" = "$version$"
"- I" = "$eth$"
"- w" = "$warn$"
"- c" = "$crit$"
}
}
: wq
# vi/etc/icinga2/conf.d/services.conf
Apply Service "nas_traffic_in" {
Import "generic-service"
Check_command = "nas-traffic-in"
Vars.snmp= "public"
Vars.eth= "vif1"
Vars.version= "2c"
Vars.warn= "1150"
Vars.crit= "180200"
Vars.perf = true
Assign where host.vars.os = = "netapp"
}
: wq
# service icinga2 restart