修改 check_snmp_int.pl Nagios XI 命令的 perfdata 输出

修改 check_snmp_int.pl Nagios XI 命令的 perfdata 输出

我在 Nagios XI 上,我使用 Vmware .ova 完成安装

我正在使用下面的命令来检索通过路由器接口的实际带宽

/usr/local/nagios/libexec/check_snmp_int.pl -H x.x.x.x -C community -2 -n eth -f -k -w 1000,1000 -c 1200,1200


eth0:UP (552.9KBps/CRIT 2507.9KBps), eth1:UP (CRIT 2466.9KBps/CRIT 8087.0KBps), eth2:UP (93.0KBps/619.8KBps):(3 UP): CRITICAL | 'eth0_in_octet'=3151058755c 'eth0_out_octet'=2254878312c 'eth1_in_octet'=626765302c 'eth1_out_octet'=634153554c 'eth2_in_octet'=1137408010c 'eth2_out_octet'=160432245c

命令正在运行。

但是 perfdata 使得图表读起来很烦人:eth2_out_octet'=160432245c等等...

所以我希望以 mb/s 为单位获取这些值

我尝试使用-B -M -Y标志来调整这些值。

我可以以字节或位为单位得到结果,但永远无法以 mb/s 为单位得到结果

有人曾经遇到过这种情况并有解决方案吗?

答案1

好的,我在 Nagios XI 论坛上提问。

我所要做的是修改 check_snmp_int perl 脚本

并将变量除以 1024 两次:

$perf_out .= sprintf("%.0f",($checkperf_out_raw[0] * 8)/1024/1024) .";";
$perf_out .= ($o_warn[0]!=0) ? $o_warn[0]*$warn_factor . ";" : ";";
$perf_out .= ($o_crit[0]!=0) ? $o_crit[0]*$warn_factor . ";" : ";";
$perf_out .= "0;". $$resultf{$oid_speed[$i]} ." ";
$perf_out .= "'" . $descr[$i] ."_out_Mbps'=";
$perf_out .= sprintf("%.0f",($checkperf_out_raw[1] * 8)/1024/1024) .";";
$perf_out .= ($o_warn[1]!=0) ? $o_warn[1]*$warn_factor . ";" : ";";
$perf_out .= ($o_crit[1]!=0) ? $o_crit[1]*$warn_factor . ";" : ";";
$perf_out .= "0;". $$resultf{$oid_speed[$i]} ." ";

相关内容