This support forum board is for support questions relating to
Nagios XI , our flagship commercial network monitoring solution.
thenomad
Posts: 35 Joined: Thu Mar 03, 2016 10:55 am
Post
by thenomad » Thu Mar 03, 2016 11:22 am
the output from check_snmp while correct is pretty nasty looking.
I simply want the status of the query not the whole query as an output
Code: Select all
/usr/bin/snmpget -Le -t 1 -r 5 -m '' -v 1 [authpriv] no.no.no.no:161 .1.3.6.1.4.1.9.9.171.1.2.1.1.0
iso.3.6.1.4.1.9.9.171.1.2.1.1.0 = Gauge32: 0
SNMP OK - 0
I just want SNMP OK - 0
Thanks
hsmith
Agent Smith
Posts: 3539 Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:
Post
by hsmith » Thu Mar 03, 2016 11:28 am
You can make a wrapper script that calls check_snmp, and then pipes the output into a
tail -n1 command.
Code: Select all
#!/bin/bash
check_snmp something something something | tail -n1
Then you set your command definition to use that script instead of check_snmp. Obviously substitute "something something something" for more useful information.
Former Nagios Employee.
me.
thenomad
Posts: 35 Joined: Thu Mar 03, 2016 10:55 am
Post
by thenomad » Thu Mar 03, 2016 11:41 am
works from the terminal ok but I seem not to be able to build the pipe into the service as it causes the command to malform from the service configuration
Code: Select all
COMMAND: /usr/local/nagios/libexec/check_snmp -H no.no.no.no -v 2c -C myspace -o .1.3.6.1.4.1.9.9.171.1.2.1.1.0 -w3 -c6 \| tail -n1
OUTPUT: Usage:
check_snmp -H <ip_address> -o <OID> [-w warn_range] [-c crit_range]
[-C community] [-s string] [-r regex] [-R regexi] [-t timeout] [-e retries]
[-l label] [-u units] [-p port-number] [-d delimiter] [-D output-delimiter]
[-m miblist] [-P snmp version] [-L seclevel] [-U secname] [-a authproto]
[-A authpasswd] [-x privproto] [-X privpasswd]
thenomad
Posts: 35 Joined: Thu Mar 03, 2016 10:55 am
Post
by thenomad » Thu Mar 03, 2016 11:46 am
D'oh ... I figured it out
Thanks for your help
hsmith
Agent Smith
Posts: 3539 Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:
Post
by hsmith » Thu Mar 03, 2016 11:49 am
Glad you got it. Would you like this topic closed?
Former Nagios Employee.
me.