Problem with check_snmp using the rate option

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Post Reply
wleight
Posts: 4
Joined: Mon May 20, 2024 2:55 pm

Problem with check_snmp using the rate option

Post by wleight »

Hi,
I'm new to Nagios, I'm trying to set up bandwidth monitoring on a switch using Nagios core. If I run the following from the command line, everything works as expected:

root@c4c537d8bc4c:/# /opt/nagios/libexec/check_snmp -C <community> -o ifHCInOctets.525 -m IF-MIB -H 172.20.170.1 -v
/usr/bin/snmpget -Le -t 3 -r 5 -m IF-MIB -v 1 [context] [authpriv] 172.20.170.1:161 ifHCInOctets.525
IF-MIB::ifHCInOctets.525 = Counter64: 450005227860107
SNMP OK - 450005227860107 | IF-MIB::ifHCInOctets.525=450005227860107c

But if I add the rate option, I get an error:

root@c4c537d8bc4c:/# /opt/nagios/libexec/check_snmp -C <community> -o ifHCInOctets.525 -m IF-MIB -H 172.20.170.1 -v --rate
/usr/bin/snmpget -Le -t 3 -r 5 -m IF-MIB -v 1 [context] [authpriv] 172.20.170.1:161 ifHCInOctets.525
IF-MIB::ifHCInOctets.525 = Counter64: 450000570156599
No valid data returned (450000570156599)

Looking at the source code (https://github.com/nagios-plugins/nagio ... nmp.c#L509), this error seems to mean that there are no integers in the returned value, but obviously there are integers there, so I'm a bit confused about what could be going on. Does anybody have any idea what the issue is here? If it matters, I'm using the jasonrivers Docker installation.

many thanks,

will
User avatar
lgute
Posts: 131
Joined: Mon Apr 06, 2020 2:49 pm

Re: Problem with check_snmp using the rate option

Post by lgute »

Hi @wleight, thanks for reaching out.

Not an SNMP expert, so I am guessing here. From the documentation I can find, ifHCInOctets, is a COUNTER64 (Octal) value, instead of an INTEGER. So maybe that is the issue?
Please let us know if you have any other questions or concerns.

-Laura
wleight
Posts: 4
Joined: Mon May 20, 2024 2:55 pm

Re: Problem with check_snmp using the rate option

Post by wleight »

Hi @lgute, thanks for your reply! The man page for check_snmp says about the --rate option: "In many places, SNMP returns counters that are only meaningful when calculating the counter difference since the last check." So I had thought that it should work ok with counters. Also, I checked with ifIndex, which does return an integer, and I still got the same error:

root@c4c537d8bc4c:/# /opt/nagios/libexec/check_snmp -C <community> -o ifIndex.525 -m IF-MIB -H 172.20.170.1 -v --rate
/usr/bin/snmpget -Le -t 3 -r 5 -m IF-MIB -v 1 [context] [authpriv] 172.20.170.1:161 ifIndex.525
IF-MIB::ifIndex.525 = INTEGER: 525
No valid data returned (525)

thanks,

will
User avatar
tgriep
Madmin
Posts: 9179
Joined: Thu Oct 30, 2014 9:02 am

Re: Problem with check_snmp using the rate option

Post by tgriep »

You may need to add the multiplier option to the check to see if that allows the rate calculation.

Code: Select all

/opt/nagios/libexec/check_snmp -C <community> -o ifHCInOctets.525 -m IF-MIB -H 172.20.170.1 --rate --multiplier=1 -v
One thing that does not look right, when you ran the command without the rate option and then with the rate option, the counter value went backwards. Is your example of the rate output from before the example without the rate option was ran?
Can you run the plugin with the rate option twice waiting 10 to 20 seconds between the runs to see if the data increments?

What OS and release are you running the plugin on?

Run this and post the output so we can see what version of the plugin.

Code: Select all

/opt/nagios/libexec/check_snmp -V

Thank You.
Be sure to check out our Knowledgebase for helpful articles and solutions!
wleight
Posts: 4
Joined: Mon May 20, 2024 2:55 pm

Re: Problem with check_snmp using the rate option

Post by wleight »

Hi @tgriep,

Sorry, yes, I just picked two examples and they were in reverse chronological order. It does increment:

root@c4c537d8bc4c:/# /opt/nagios/libexec/check_snmp -C <community> -o ifHCInOctets.525 -m IF-MIB -H 172.20.170.1 -v --multiplier=1 --rate
/usr/bin/snmpget -Le -t 3 -r 5 -m IF-MIB -v 1 [context] [authpriv] 172.20.170.1:161 ifHCInOctets.525
IF-MIB::ifHCInOctets.525 = Counter64: 455351645327226
No valid data returned (455351645327226)
root@c4c537d8bc4c:/# /opt/nagios/libexec/check_snmp -C <community> -o ifHCInOctets.525 -m IF-MIB -H 172.20.170.1 -v --multiplier=1 --rate
/usr/bin/snmpget -Le -t 3 -r 5 -m IF-MIB -v 1 [context] [authpriv] 172.20.170.1:161 ifHCInOctets.525
IF-MIB::ifHCInOctets.525 = Counter64: 455351645923068
No valid data returned (455351645923068)

However, as you can see, the --multiplier=1 option doesn't seem to help.

I'm using the jasonrivers docker build (https://github.com/JasonRivers/Docker-Nagios) which uses Nagios Core 4.4.14 running on Ubuntu 22.04 LTS. The version of check_snmp is:

root@c4c537d8bc4c:/# /opt/nagios/libexec/check_snmp -V
check_snmp v2.4.6.22.gee69 (nagios-plugins 2.4.7)

thanks for your help!

will
User avatar
tgriep
Madmin
Posts: 9179
Joined: Thu Oct 30, 2014 9:02 am

Re: Problem with check_snmp using the rate option

Post by tgriep »

I tested on version 2.4.5 and 2.4.10 of the plugin and they both work.

One thing else it could be. When using the rate option, it creates a state file to use for the calculations and maybe that is the issue, a bad state file.

The thing is, I do not know how the plugin was compiled on that docker so I cannot give a definitive path to where it is.

I would look here first to see if there is a check_snmp sub directory

Code: Select all

/opt/nagios/var/0
Like this

Code: Select all

/opt/nagios/var/0/check_snmp
Delete the files in there and run the rate command twice to see if it works.

But if you look in the latest plugin change log, it looks like it is a known issue and has been fixed in a newer version.
2.4.9 2024-03-21
FIXES
check_snmp: Robustly fixes incorrect integer return value parsing (#749)

2.4.8 2023-12-7
FIXES
check_snmp: Fixed issue where Timeticks would incorrectly show "No valid data returned" (#743)
Here is a link to compile the plugins from source.
https://support.nagios.com/kb/article/n ... e-569.html

But the paths are different then what the docker uses for the default location when it is compiled, it uses this for the state file location.

Code: Select all

/usr/local/nagios/var/0/check_snmp
Thank You.
Be sure to check out our Knowledgebase for helpful articles and solutions!
wleight
Posts: 4
Joined: Mon May 20, 2024 2:55 pm

Re: Problem with check_snmp using the rate option

Post by wleight »

Hi @tgriep,

Ah, I should have thought to check for a newer version. I upgraded to 2.4.10 and it works now, thanks very much for your help!

will
Post Reply