check_snmp - Dividing Output

An open discussion forum for obtaining help with Nagios Core. Nagios Core users of all experience levels are welcome here. Subforum have been created for the discussion of Nagios Core and Nagios Plugin development.

NOTE: The mailing lists have been deprecated in favor of this forum in order to expedite support and provide additional features not available on the old mailing list.

check_snmp - Dividing Output

Postby Eireocean » Thu Nov 28, 2019 3:25 am

Good Day,

We are moitoring UPS's via a SNMP Card. Some of the values, however, need to be divided by 10 to get proper value. In the forums, I cam accross this solution :

Code: Select all
/usr/local/nagios/libexec/check_snmp -H $hostaddress -C public -o  | awk -F'|' '{split($1,array_left,"-");} {split($2,array_right,"=");} {print array_left[1]"- "array_left[2]/10"|"array_right[1]"="array_right[2]/10;}'

That works perfectly ... but, we need to set thresholds and this is where it fails as the output differs between a status of Ok and Warning / Critical :

SNMP OK - 2178 | iso.

SNMP CRITICAL - *2180* | iso.;2300:;2300:

Has anyone successfully implemented something that we are trying accomplsih ?

Posts: 19
Joined: Tue Oct 11, 2016 2:23 am

Re: check_snmp - Dividing Output

Postby mcapra » Mon Dec 02, 2019 10:22 am

You could give this a try: ... dd/details

Haven't used this plugin before, but the code looks like it does what you want. You'd simply multiply by 0.1 instead of dividing by 10. Assuming Nagios::Plugin does the threshold calculations I guess? There's no comparisons to warning/critical being done in the above code.
Former Nagios employee
User avatar
Posts: 3591
Joined: Thu May 05, 2016 3:54 pm

Re: check_snmp - Dividing Output

Postby mbellerue » Mon Dec 02, 2019 2:22 pm

Thanks for jumping in, Matt!

@Eireocean, does Matt's suggested plugin work for your needs?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
Posts: 1191
Joined: Fri Jul 12, 2019 11:10 am

Return to Nagios Core

Who is online

Users browsing this forum: eoggian and 36 guests