Page 1 of 1

using check_snmp with oid that has multi-line output

Posted: Wed Oct 27, 2021 1:51 pm
by ajwilliamson
Hi,

I'm trying to use check_snmp to monitor a Dell switch.

The oid in particular that i'm trying to read returns output across multiple lines.

Code: Select all

/usr/local/nagios/libexec/check_snmp -H 10.32.1.122  -p 161 -o '.1.3.6.1.2.1.1.1.0' -P 3 --seclevel=authPriv --secname='SOMEUSER' --authproto=SHA --authpasswd='somepassword' --privpasswd='someotherpassword' -x aes
 | P OK - Dell EMC Networking OS10 Enterprise.
.1.3.6.1.2.1.1.1.0:
"Dell EMC Networking OS10 Enterprise.
Copyright (c) 1999-2021 by Dell Inc. All Rights Reserved.
System Description: OS10 Enterprise.
OS Version: 10.5.2.7.
System Type: S3048-ON"
My goal here is to look for the string "10.5.2.7"...so I tried using the -r parameter to do a regex against the output ( -r '10.5.2.7' ), but it fails and my fear is that it is only searching the first line of output.

I tried using more specific and complex regular expressions to no avail (eg '/10\.5\.2\.7/gms' ).

Code: Select all

/usr/local/nagios/libexec/check_snmp -H 10.32.1.122  -p 161 -o '.1.3.6.1.2.1.1.1.0' -P 3 --seclevel=authPriv --secname='SOMEUSER' --authproto=SHA --authpasswd='somepassword' --privpasswd='someotherpassword' -x aes -r '10.5.2.7'
* |  CRITICAL - *Dell EMC Networking OS10 Enterprise.
.1.3.6.1.2.1.1.1.0:
"Dell EMC Networking OS10 Enterprise.
Copyright (c) 1999-2021 by Dell Inc. All Rights Reserved.
System Description: OS10 Enterprise.
OS Version: 10.5.2.7.
System Type: S3048-ON"
Am I missing something?

Any help would be appreciated. Thanks.

Re: using check_snmp with oid that has multi-line output

Posted: Wed Oct 27, 2021 6:34 pm
by ssax
It doesn't look like check_snmp supports multi-line output, I am able to replicate the issue.

What is the output of this command?

Code: Select all

snmpbulkget -v3 -u yoursnmpv3user -A 'authPass' -a SHA -X 'privPass' -x AES -l authPriv X.X.X.X:161 .1.3.6.1.2.1.1.1.0

Re: using check_snmp with oid that has multi-line output

Posted: Thu Oct 28, 2021 7:56 am
by ajwilliamson
Here is the output of that command:

Code: Select all

 snmpbulkget -v 3 -l AuthPriv -u SOMEUSER -a SHA -A somepassword -x AES -X someotherpassword 10.32.1.112 .1.3.6.1.2.1.1.1.0
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.674.11000.5000.100.2.1.4
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (23442779) 2 days, 17:07:07.79
SNMPv2-MIB::sysContact.0 = STRING: [email protected]
SNMPv2-MIB::sysName.0 = STRING: USEDC-SWA112
SNMPv2-MIB::sysLocation.0 = STRING: USEDC
SNMPv2-MIB::sysServices.0 = INTEGER: 72
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (26) 0:00:00.26
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: SNMP-VIEW-BASED-ACM-MIB::vacmBasicGroup
SNMPv2-MIB::sysORID.3 = OID: TCP-MIB::tcpMIB

Re: using check_snmp with oid that has multi-line output

Posted: Fri Oct 29, 2021 2:26 pm
by benjaminsmith
Hi,

Since this plugin is open-source, would you be able to directly open an issue for regex support for multiline output on the GitHub page?

https://github.com/nagios-plugins/nagios-plugins

Let us know.

Thanks,
Benjamin

Re: using check_snmp with oid that has multi-line output

Posted: Fri Oct 29, 2021 3:56 pm
by ajwilliamson
I have posted the above on GitHub: https://github.com/nagios-plugins/nagio ... issues/629

Thanks

Re: using check_snmp with oid that has multi-line output

Posted: Fri Oct 29, 2021 5:01 pm
by benjaminsmith
Hi,

Appreciate it. I will follow up on this with the team here as well.

Have a great weekend!