SNMP using PREEXEC

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
User avatar
setec
Posts: 10
Joined: Thu Jan 16, 2014 11:24 am

SNMP using PREEXEC

Post by setec »

Seems like this is an acceptable command:

PREEXEC snmpget -v 2c -Ovq -c $C $aA ifAlias.$1

However, I'm not receiving anything back except when I statically put in a community name. Does $C not work for PREEXEC? It's listed in the macros. Thanks.
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: SNMP using PREEXEC

Post by mbellerue »

We ran a test on our systems, and $C works with PREEXEC.

It could be the location of PREEXEC in your EVENT block. Could you post the affected block here for us to take a look?
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
setec
Posts: 10
Joined: Thu Jan 16, 2014 11:24 am

Re: SNMP using PREEXEC

Post by setec »

You'll have to be explicit with what you'll need as I'm still learning the in's and out's of SNMP with Nagios. Shoot me the commands to get the info you are looking for and I'll post the output. Thanks.
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: SNMP using PREEXEC

Post by mbellerue »

Okay, grab the /etc/snmp/snmptt.conf file from your Nagios XI server, and PM that over to me.
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
setec
Posts: 10
Joined: Thu Jan 16, 2014 11:24 am

Re: SNMP using PREEXEC

Post by setec »

Sent, thank you.

Essentially this is what I get from linkDown OID when using "PREEXEC snmpget -v 2c -Ovq -c $C $aA ifAlias.$1" in the Advanced box under SNMP Trap Interface:
Link down on interface GigabitEthernet1/0/12 ((no output from PREEXEC)

Using the following in Service Output:
Link down on interface $2 ($p1). Operational State: $4.
User avatar
mbellerue
Posts: 1403
Joined: Fri Jul 12, 2019 11:10 am

Re: SNMP using PREEXEC

Post by mbellerue »

I'm not seeing the PREEXEC line in snmptt.conf. Maybe just zip up all of the files in /etc/snmp/ and send that zip over. We'll find it.
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
setec
Posts: 10
Joined: Thu Jan 16, 2014 11:24 am

Re: SNMP using PREEXEC

Post by setec »

Looks like it's the first OID in snmptt.conf.nxti:

### AUTO-GENERATED BY NXTI. DO NOT HAND-EDIT THIS FILE. ###
EVENT linkDown .1.3.6.1.6.3.1.1.5.3 "Status Events" Critical
FORMAT Received trap "$N" with variables "$+*"
EXEC php /usr/local/nagiosxi/scripts/nxti.php --event_name="$N" --event_oid="$i" --numeric_oid="$o" --symbolic_oid="$O" --community="$C" --trap_hostname="$R" --trap_ip="$aR" --agent_hostname="$A" --agent_ip="$aA" --category="$c" --severity="$s" --uptime="$T" --datetime="$x $X" --unixtime="$@" --bindings="$+*"
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Trap - Interface" "$s" "$@" "" "Link down on interface $2 ($p1). Operational State: $4."
PREEXEC snmpget -v 2c -Ovq -c $C $aA ifAlias.$1
SDESC
A linkDown trap signifies that the SNMP entity, acting inan agent role, has detected that the ifOperStatus object forone of its communication links is about to enter the downstate from some other state (but not from the notPresentstate). This other state is indicated by the included valueof ifOperStatus.Variables: 1: ifIndex 2: ifAdminStatus 3: ifOperStatus
EDESC
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: SNMP using PREEXEC

Post by tgriep »

I have a couple of changes you can try to see if they help.

Use the full path to the snmpget command and put double quotes around the $C
PREEXEC /usr/bin/snmpget -v 2c -Ovq -c "$C" $aA ifAlias.$1

What sort of output do you get when the PREEXEC runs?
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
setec
Posts: 10
Joined: Thu Jan 16, 2014 11:24 am

Re: SNMP using PREEXEC

Post by setec »

Getting the following output (using PREEXEC /usr/bin/snmpget -v 2c -Ovq -c "$C" $aA ifAlias.$1 and PREEXEC snmpget -v 2c -Ovq -c "$C" $aA ifAlias.$1):

Link down on interface GigabitEthernet1/0/12 ((no output from PREEXEC)
-

But if I statically put in the SNMP community I'll get:

Link down on interface GigabitEthernet1/0/12 (TEST INTERFACE DESCRIPTION)
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: SNMP using PREEXEC

Post by tgriep »

One more thing to try.
Swap the EXEC and the PREEXEC lines in the config file and restart snmptt to see if it works.

Code: Select all

PREEXEC snmpget -v 2c -Ovq -c $C $aA ifAlias.$1
EXEC php /usr/local/nagiosxi/scripts/nxti.php --event_name="$N" --event_oid="$i" --numeric_oid="$o" --symbolic_oid="$O" --community="$C" --trap_hostname="$R" --trap_ip="$aR" --agent_hostname="$A" --agent_ip="$aA" --category="$c" --severity="$s" --uptime="$T" --datetime="$x $X" --unixtime="$@" --bindings="$+*"
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Trap - Interface" "$s" "$@" "" "Link down on interface $2 ($p1). Operational State: $4."
Also, what version of snmptt is on your server.
Run this and post it here.

Code: Select all

snmptt -V
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked