icinga2监控netapp、ubuntu、windows的traffic流量
插件下载网址: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
说明:之所以弄in和out出来,是为了后面出图像,默认该脚本只显示Interval指标的图像,不过没什么用,需在出图像后(需先有图像出来),将脚本最后的
$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\=${uOut}${Unit_1}${Unit_2}\;${W2}\;${C2}\;0\;0 Total\=${uTotal}${Unit_1}${Unit_2}\;${Wt}\;${Ct}\;0\;0 Interval\=${Interval}s\;1200\;1800\;0\;0
改为
$Echo "$Msg" "-" The Traffic In is "$uIn"${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\=${uOut}${Unit_1}${Unit_2}\;${W2}\;${C2}\;0\;0 Total\=${uTotal}${Unit_1}${Unit_2}\;${Wt}\;${Ct}\;0\;0 In\=${uIn}${Unit_1}${Unit_2}\;1200\;1800\;0\;0
另建议对Min_Interval和Max_Interval做下调整
Min_Interval=0 (默认为30s,即隔30s才能执行第2次)
Max_Interval=5800 (默认为1800,不修改netapp会报错)
另如不想设warning、crit等报警(在此处没多大意义,主要是要图像,可将脚本里关于OK、warning、crit等if语句删掉)
使用:
Ubuntu:
# /usr/lib64/nagios/plugins/check_traffic_in.sh -V 2c -H 10.0.0.88 -C public -N em1 -w 1,50 -c 180,200 (Ubuntu 14.04以上为em1,之前为eth0,-V是指snmp的版本)
Netapp:
# /usr/lib64/nagios/plugins/check_traffic.sh -V 2c -H 10.0.1.10 -C public -N vif1 -w 1,200 -K -B (vif1是指存储的网卡,-K -B可不加)
Windows:
# /usr/lib64/nagios/plugins/check_traffic_in.sh -V 2c -H 172.16.0.3 -C public -I 1 -w 1,200 (1是指本地连接1)
示例(netapp,ubuntu,windows参考调整即可,eth0、本地连接2等单独弄个services.conf项即可)
# 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="1,150"
vars.crit="180,200"
vars.perf = true
assign where host.vars.os == "netapp"
}
:wq
# service icinga2 restart
原文链接:https://www.f2er.com/ubuntu/355758.html