check_snmp and Status Information output is different

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.
Locked
romeor
Posts: 25
Joined: Mon Aug 30, 2010 1:16 am

check_snmp and Status Information output is different

Post by romeor »

Hi,

I'm having such an issue. When I run the check_snmp command from the terminal, I get this output:

Code: Select all

:/usr/lib/nagios/plugins# ./check_snmp -H IP -o JUNIPER-MIB::jnxOperatingState.4.1.1.0 -C <community> -m JUNIPER-MIB 
SNMP OK - running(2) |
SNMPGET return:

Code: Select all

:/usr/lib/nagios/plugins# snmpget -v2c -c <community>  IP JUNIPER-MIB::jnxOperatingState.4.1.1.0
JUNIPER-MIB::jnxOperatingState.4.1.1.0 = INTEGER: running(2)
But Nagios interface shows me truncated information:

Code: Select all

Status Information:	SNMP OK - 2
which returns me only OK and integer..

But I would like to see the full plugin output... May be I missed something? Could anyone help me to resolve this issue? I believe it should be easy done by some setting, I missed...
Last edited by romeor on Mon Nov 16, 2015 6:51 pm, edited 1 time in total.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_snmp and Status Information output is different

Post by rkennedy »

What happens if you add the -v (verbose) flag to the command - does that produce the result you're looking for?
Former Nagios Employee
romeor
Posts: 25
Joined: Mon Aug 30, 2010 1:16 am

Re: check_snmp and Status Information output is different

Post by romeor »

Thanks for quick reply!

If I add the -v, it becomes too verbose...

Code: Select all

/usr/bin/snmpget -Le -t 1 -r 5 -m JUNIPER-MIB -v 2c [authpriv] IP:161 JUNIPER-MIB::jnxOperatingState.4.1.1.0
JUNIPER-MIB::jnxOperatingState.4.1.1.0 = INTEGER: running(2)
SNMP OK - 2

my goal is to see only this:

Code: Select all

SNMP OK - running(2) 
the mib can have these states:

Code: Select all

    jnxOperatingState OBJECT-TYPE
        SYNTAX          INTEGER {
                unknown(1),
                running(2),   -- up and running,
                              -- as a active primary
                ready(3),     -- ready to run, not running yet
                reset(4),     -- held in reset, not ready yet
                runningAtFullSpeed(5),
                              -- valid for fans only
                down(6),      -- down or off, for power supply
                standby(7)    -- running as a standby backup
        }
So me and NOC would be happy to see not only the integer, but some text next to it, which is a short description.

Sure I can operate with grep and awk, but isn't there any more beautiful way?
Last edited by romeor on Mon Nov 16, 2015 1:54 pm, edited 1 time in total.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: check_snmp and Status Information output is different

Post by rkennedy »

When I mentioned the -v flag, I meant to add that to Nagios. What's the result look like when running it with ./check_snmp (over CLI and the web interface)?
Former Nagios Employee
romeor
Posts: 25
Joined: Mon Aug 30, 2010 1:16 am

Re: check_snmp and Status Information output is different

Post by romeor »

Now I need your help with this :)
Where do I add it ? What do you mean by "add to Nagios"? Is there any startup options list in config file or something?
I run Nagios under Debian 8

and afaik -v flag is used with Nagio binary to verify the config file...

Ok we've got a mess.

I did first time add a -v to the check_snmp command actually.

so result was like

Code: Select all

:/usr/lib/nagios/plugins# ./check_snmp -H IP -P 2c -o JUNIPER-MIB::jnxOperatingState.4.1.1.0 -C -m JUNIPER-MIB -v
/usr/bin/snmpget -Le -t 1 -r 5 -m JUNIPER-MIB -v 2c [authpriv] IP:161 JUNIPER-MIB::jnxOperatingState.4.1.1.0
JUNIPER-MIB::jnxOperatingState.4.1.1.0 = INTEGER: running(2)
SNMP OK - running(2) |
in CLI

and like this in Web:

Code: Select all

/usr/bin/snmpget -Le -t 1 -r 5 -m JUNIPER-MIB -v 2c [authpriv] IP:161 JUNIPER-MIB::jnxOperatingState.4.1.1.0
JUNIPER-MIB::jnxOperatingState.4.1.1.0 = INTEGER: running(2)
SNMP OK - 2
which is too verbose.
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: check_snmp and Status Information output is different

Post by hsmith »

The easiest way to do this is going to be to write a wrapper script. You call the wrapper script instead of the SNMP plugin. You call the wrapper script instead of the SNMP plugin.

For instance... I made a simple bash script that does this to simulate what you would be getting from an SNMP command, I don't have your device, so I can't test it. You would replace these echo commands with your SNMP command from your service definition.

Code: Select all

echo "/usr/bin/snmpget -Le -t 1 -r 5 -m JUNIPER-MIB -v 2c [authpriv] IP:161 JUNIPER-MIB::jnxOperatingState.4.1.1.0"
echo "JUNIPER-MIB::jnxOperatingState.4.1.1.0 = INTEGER: running(2)"
echo "SNMP OK - 2"
And from the command line, I did this:

Code: Select all

./mywrapper | tail -n2
Which returns:

Code: Select all

JUNIPER-MIB::jnxOperatingState.4.1.1.0 = INTEGER: running(2)
SNMP OK - 2
Do you get the idea of what I am saying here?
Former Nagios Employee.
me.
romeor
Posts: 25
Joined: Mon Aug 30, 2010 1:16 am

Re: check_snmp and Status Information output is different

Post by romeor »

Sure, I do. Thank you for sharing your idea.
But if I am going to wrappers, then I would do it this way:

Code: Select all

./check_snmp -H IP -P 2c -o JUNIPER-MIB::jnxOperatingState.4.1.1.0 -C community -m JUNIPER-MIB -v | grep INTEGER  | awk '{ print $4}'
I just thought there is more elegant way of doing this. Each kind of external commands calling is pretty costy for high loaded systems.
Or just will have to write my own plugin.

Thanks again.
Locked