Page 1 of 1

Having Mb/s values in perfdata of check_snmp_int.pl command

Posted: Mon Aug 07, 2017 7:51 am
by Norshok
Hello

I'm on Nagios XI, i used the Vmware .ova to get the install done

I am using the command below to get the actual bandwidth that go through the interfaces of a router

/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

the command is working.

But the perfdata make the graph annoying to read : "eth2_out_octet'=160432245c" , etc ...

so i would like to have those values in mb/s

i tried to use the -B -M -Y to tweak those values.

I could have the results in bytes or in bits but i could never have them in mb/s

do someone experienced this before and have a solution ?

Thanks

Re: Having Mb/s values in perfdata of check_snmp_int.pl comm

Posted: Mon Aug 07, 2017 3:20 pm
by bolson
Hello Norshok,

You're correct. The check command only gives you the option of returning values in bits or bytes. If you know perl, you could do math in the script itself, ie: B / 1024 / 1024

Re: Having Mb/s values in perfdata of check_snmp_int.pl comm

Posted: Wed Aug 09, 2017 6:05 pm
by Norshok
Alright, It worked

$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]} ." ";

Thank you

Re: Having Mb/s values in perfdata of check_snmp_int.pl comm

Posted: Thu Aug 10, 2017 9:28 am
by bolson
May we close this topic?

Re: Having Mb/s values in perfdata of check_snmp_int.pl comm

Posted: Fri Aug 11, 2017 5:05 am
by Norshok
Yes, thanks again for the help :)

Re: Having Mb/s values in perfdata of check_snmp_int.pl comm

Posted: Fri Aug 11, 2017 9:39 am
by bolson
Closing topic as resolved.

Thank you for using the Nagios Support Forum.