Page 1 of 2
SNMP using PREEXEC
Posted: Mon Sep 09, 2019 2:19 pm
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.
Re: SNMP using PREEXEC
Posted: Tue Sep 10, 2019 1:13 pm
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?
Re: SNMP using PREEXEC
Posted: Tue Sep 10, 2019 4:09 pm
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.
Re: SNMP using PREEXEC
Posted: Tue Sep 10, 2019 4:45 pm
by mbellerue
Okay, grab the /etc/snmp/snmptt.conf file from your Nagios XI server, and PM that over to me.
Re: SNMP using PREEXEC
Posted: Wed Sep 11, 2019 12:50 pm
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.
Re: SNMP using PREEXEC
Posted: Thu Sep 12, 2019 11:04 am
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.
Re: SNMP using PREEXEC
Posted: Mon Sep 16, 2019 2:10 pm
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
Re: SNMP using PREEXEC
Posted: Mon Sep 16, 2019 4:30 pm
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?
Re: SNMP using PREEXEC
Posted: Mon Sep 16, 2019 4:50 pm
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)
Re: SNMP using PREEXEC
Posted: Mon Sep 16, 2019 4:55 pm
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.