SNMPTT PREEXEC questions
Posted: Tue Sep 11, 2018 8:40 pm
We are trying to get more information from our SNMP traps and we are looking for a way to find more detail. We trap on up/down of interfaces but is there a way to get more information (like a description) from the trap for link down (.1.3.6.1.6.3.1.1.5.3) and link up (.1.3.6.1.6.3.1.1.5.4)? I know the data is not contained within the trap itself but I was possibly looking for a way to pull the corresponding description entry from the ifxAlias table at this OID: 1.3.6.1.2.1.31.1.1.1.18. I am thinking that since the trap shows the ifindex, we can strip that ifindex number off and do an snmp get of 1.3.6.1.2.1.31.1.1.1.18.[ifindex], then we could return the interface description with the trap.
From some research, I found that I may be able to do a PREEXEC in SNMPTT like this:
PREEXEC /usr/bin/snmpget -v2c -Ovq -c snmppassword $aA 1.3.6.1.2.1.31.1.1.1.18.$1
and then have the EXEC line use that output like this:
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$p1" "$@" "$-*" "LINK DOWN, $*"
If I go this route, I would likely have to do some preprocessing as that OID returns "description" at the beginning and I would likely want to strip that out.
Also, since the PREEXEC requires the sending of the SNMP credentials (we use v2 and v3), is there some way to get that information from the Nagios system since we had to configure that in the system? I know the interface check command includes it like so: "check_xi_service_ifoperstatus!snmppassword!7!-v 2 -p 161" but is that "snmppassword" value stored as a variable anywhere where I can get my hands on it for a script?
We are looking for best practices or some recommendations to getting this working the best way possible.
From some research, I found that I may be able to do a PREEXEC in SNMPTT like this:
PREEXEC /usr/bin/snmpget -v2c -Ovq -c snmppassword $aA 1.3.6.1.2.1.31.1.1.1.18.$1
and then have the EXEC line use that output like this:
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$p1" "$@" "$-*" "LINK DOWN, $*"
If I go this route, I would likely have to do some preprocessing as that OID returns "description" at the beginning and I would likely want to strip that out.
Also, since the PREEXEC requires the sending of the SNMP credentials (we use v2 and v3), is there some way to get that information from the Nagios system since we had to configure that in the system? I know the interface check command includes it like so: "check_xi_service_ifoperstatus!snmppassword!7!-v 2 -p 161" but is that "snmppassword" value stored as a variable anywhere where I can get my hands on it for a script?
We are looking for best practices or some recommendations to getting this working the best way possible.