Sorry, I stepped away for a bit and am revisiting this now. I am having a hard time putting it all together... Let's use this for an example. I have multiple devices using NAS-MIB (QNAP device) that is sending traps. snmptt.conf is configured as follows:
Code: Select all
MIB: NAS-MIB (file:/usr/share/snmp/mibs/NAS.mib) converted on Wed Aug 17 15:50:21 2016 using snmpttconvertmib v1.4beta2
#
#
#
EVENT eventInform .1.3.6.1.4.1.24681.1.10.0.1 "Status Events" Normal
FORMAT Info: $1
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "Info: $1"
SDESC
Info: %s
Variables:
1: eventInformMsg
EDESC
#
#
#
EVENT eventWarning .1.3.6.1.4.1.24681.1.10.0.2 "Status Events" Normal
FORMAT $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
Warn: %s
Variables:
1: eventWarningMsg
EDESC
#
#
#
EVENT eventError .1.3.6.1.4.1.24681.1.10.0.4 "Status Events" Normal
FORMAT $*
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "$*"
SDESC
Error: %s
Variables:
1: eventErrorMsg
EDESC
I have a small Linux device at customer premise. Using NRDS, I have setup check_ping for 2 QNAP devices:
Code: Select all
command[__HOST__]=/usr/lib/nagios/plugins/check_ping -H localhost -w 200.0,40% -c 400.0,80% -p 1
command[QNAP 1]=/usr/lib/nagios/plugins/check_ping -H 192.168.103.201 -w 200.0,40% -c 400.0,80% -p 5
command[QNAP 2]=/usr/lib/nagios/plugins/check_ping -H 192.168.103.202 -w 200.0,40% -c 400.0,80% -p 5
The host is setup in XI, and I have 2 services, QNAP1 and QNAP2. At this point, I'm deciding if I want to run snmptt and snmptrapd locally on the Linux device or just have the QNAP send traps direct to XI via WAN -- for the example lets say I'm having the QNAP send traps directly to XI.
QNAP 1 sends a trap with OID .1.3.6.1.4.1.24681.1.10.0.4 to XI. If i look in Admin > Unconfigured Objects, I'll see a new object for "SNMP Traps" with the WAN IP of the customers site. If i add that object, everything is great, however the SNMP Traps are tied to the NRDS Hosts and not either of the 2 services (QNAP1 or QNAP2). I want to make a new service such as SNMP Traps - QNAP 1.
I know I can do this by makign multiple entries in snmptt.conf for the same OID. However, how do I match based on the IP of the trap agent?
Example: QNAP 1 sends its trap to XI. XI notices the trap agent IP address ($aA) is 192.168.103.201.
In the snmptt docs, I see I can use something like this:
..inside of an event. So I could make multiple events for each device that would be sending that specific OID, and change ....
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps" "$s" "$@" "$-*" "Info: $1"
..to something like this:
EXEC /usr/local/bin/snmptraphandling.py "$r" "SNMP Traps - QNAP 1" "$s" "$@" "$-*" "Info: $1"
Does this make sense so far? The one thing I'm struggling with is when I look at the snmptt log files on my NAGIOS server, I cannot figure out how to "extract" any of the variables/OBJECTS for the match statement. If we look at snmpttunknown.log:
Code: Select all
[root@nagios snmptt]# cat snmpttunknown.log
Sun Sep 4 19:11:39 2016: Unknown trap (.1.3.6.1.4.1.24681.1.10.0.1) received from 10.1.1.50 at:
Value 0: 10.1.1.50
Value 1: 10.1.1.50
Value 2: 7:19:50:01.73
Value 3: .1.3.6.1.4.1.24681.1.10.0.1
Value 4: 10.1.1.50
Value 5: empire
Value 6: .1.3.6.1.4.1.24681.1.10
Value 7:
Value 8:
Value 9:
Value 10:
Ent Value 0: .1.3.6.1.4.1.24681.1.1.101.0=[HDD SMART] Host: Disk 2 Rapid Test started.
..we can see that the IP address is not passed in any of the "Objects" -- so $1 would not give me anything useful for my MATCH statement. Am I able to reference Value 0 ~ Value 10 at all somehow? Or should I just try to match on an snmptt variable, like $aA?
From snmptt docs:
Code: Select all
The following command formats are available:
MATCH MODE=[or | and]
MATCH $x: [!] (reg) [i]
MATCH $x: [!] n
MATCH $x: [!] n-n
MATCH $x: [!] < n
MATCH $x: [!] > n
MATCH $x: [!] & n
MATCH $x: [!] x.x.x.x
MATCH $x: [!] x.x.x.x-x.x.x.x
MATCH $x: [!] x.x.x.x/x
where:
or or and set the default evaluation mode for ALL matches
$x is any variable (example: $3, $A etc)
reg is a regular expression
! is used to negate the result (not)
& is used to perform a bitwise AND
n is a number
x.x.x.x is an IP address
x.x.x.x-x.x.x.x is an IP network address range
x.x.x.x/x is an IP CIDR network addresss
I'm wondering if I am better off getting something like Fusion, and running Nagios Core at customer premise...