SNMP Traps in Nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
tellyfilms
Posts: 5
Joined: Wed Apr 13, 2011 9:30 am

SNMP Traps in Nagios

Post by tellyfilms »

We have built an application which will generate an SNMP trap and send this to a server with Nagios Installed to enable us to see when an exception occurs.

We are using the snmptrap daemon to listen for the trap and snmptt to translate the trap to enable Nagios to show the trap.

We have used the following page as our reference
http://xavier.dusart.free.fr/nagios/en/snmptraps.html

The mib file that we have written is

Code: Select all

ERRORBOT-MIB DEFINITIONS ::= BEGIN

          IMPORTS
               enterprises,
               OBJECT-TYPE,
               Counter
                     FROM RFC1155-SMI

               microsoft
                     FROM MSFT-MIB


                software           OBJECT IDENTIFIER ::= { microsoft 1} -- 1.3.6.1.4.1.311.1
                internetServer     OBJECT IDENTIFIER ::= { software 7 } -- 1.3.6.1.4.1.311.1.7
                ErrorBot           OBJECT IDENTIFIER ::= { internetServer 2000 } -- 1.3.6.1.4.1.311.1.7.2000
                ErrorBotHeart      OBJECT IDENTIFIER ::= { ErrorBot 2} -- 1.3.6.1.4.1.311.1.7.2000.2

-- Package Details

          OpSystem OBJECT-TYPE
                SYNTAX       OCTET STRING (SIZE(0..255))
                ACCESS       read-only
                STATUS       mandatory
                DESCRIPTION
                      "OS Version"
                ::= {ErrorBotHeart 1}

          TrapName OBJECT-TYPE
                SYNTAX       OCTET STRING (SIZE(0..255))
                ACCESS       read-only
                STATUS       mandatory
                DESCRIPTION
                      "Name of Trap"
                ::= {ErrorBotHeart 2}

          CurrStat OBJECT-TYPE
                SYNTAX       OCTET STRING (SIZE(0..255))
                ACCESS       read-only
                STATUS       mandatory
                DESCRIPTION
                      "Current Status of Trap"
                ::= {ErrorBotHeart 3}

          HeartBeatNotification NOTIFICATION-TYPE
                OBJECTS    {CurrStat}
                STATUS     current
                DESCRIPTION
                        "notification"
                ::= {ErrorBotHeart 4}

END
Our problem is when we try to compile a mib file that we have written to interpretate the trap that we are having problems with the part "Looking up via snmptranslate:" as shown below

Code: Select all

root@nagios3:/usr/share/snmp/mibs# snmpttconvertmib --in=ERRORBOT-MIB.txt --out=/etc/snmp/snmptt.conf --exec='/usr/local/nagios/libexec/submit_check_result $r TRAP 1'
exec: /usr/local/nagios/libexec/submit_check_result $r TRAP 1
 
 
*****  Processing MIB file *****
 
snmptranslate version: NET-SNMP version: 5.4.2.1
severity: Normal
 
File to load is:        ./ERRORBOT-MIB.txt
File to APPEND TO:      /etc/snmp/snmptt.conf
 
MIBS environment var:   ./ERRORBOT-MIB.txt
mib name: ERRORBOT-MIB
 
 
Processing MIB:         ERRORBOT-MIB
#
Line: 43
NOTIFICATION-TYPE: HeartBeatNotification
Variables: CurrStat
Enterprise: ErrorBotHeart
Looking up via snmptranslate: ERRORBOT-MIB::HeartBeatNotification
Unknown object identifier: ERRORBOT-MIB::HeartBeatNotification
OID:
 
 
Done
 
Total translations:        1
Successful translations:   0
Failed translations:       1
root@nagios3:/usr/share/snmp/mibs#
We have tried to use the following as a guide in trying to get this to work.
http://www.net-snmp.org/docs/mibs/NET-S ... ES-MIB.txt

However when we try to import the NOTIFICATION-TYPE we get a warning about skipping a line as shown below.

Code: Select all

root@nagios3:/usr/share/snmp/mibs# snmpttconvertmib --in=ERRORBOT-MIB.txt --out=/etc/snmp/snmptt.conf --exec='/usr/local/nagios/libexec/submit_check_result $r TRAP 1'
exec: /usr/local/nagios/libexec/submit_check_result $r TRAP 1
 
 
*****  Processing MIB file *****
 
snmptranslate version: NET-SNMP version: 5.4.2.1
severity: Normal
 
File to load is:        ./ERRORBOT-MIB.txt
File to APPEND TO:      /etc/snmp/snmptt.conf
 
MIBS environment var:   ./ERRORBOT-MIB.txt
mib name: ERRORBOT-MIB
 
 
Processing MIB:         ERRORBOT-MIB
skipping a TRAP-TYPE / NOTIFICATION-TYPE line - probably an import line.
#
Line: 44
NOTIFICATION-TYPE: HeartBeatNotification
Variables: CurrStat
Enterprise: ErrorBotHeart
Looking up via snmptranslate: ERRORBOT-MIB::HeartBeatNotification
Unknown object identifier: ERRORBOT-MIB::HeartBeatNotification
OID:
 
 
Done
 
Total translations:        1
Successful translations:   0
Failed translations:       1
Can anyone please help us with this specific scenario as we are newbies in this area but we have been trying to get this to work for some time :)

or Can anybody direct us to a good example of a mib which has been written to handle a user generated trap that can be shown in Nagios.

All help will be much appreciated.
tellyfilms
Posts: 5
Joined: Wed Apr 13, 2011 9:30 am

Re: SNMP Traps in Nagios

Post by tellyfilms »

In addition to the original post I have put in the semi-colon after the import section and the translation was successful, however the NOTIFICATION-TYPE line was still skipped.
User avatar
niebais
Posts: 349
Joined: Tue Apr 13, 2010 2:15 pm

Re: SNMP Traps in Nagios

Post by niebais »

I had the same issue with traps. They are unnecessarily difficult to configure and set up. I ended up just using snmp gets as Nagios is set up pretty good for that. Also, traps were way too chatty and ended up spamming the engineers when we had them set up making them practically useless.

I'm not a huge fan of SNMP after working with it. Trap handling in worked fine with some of our routers and switches, but we ended up abandoning traps alltogether.

Here's a good utility to help you find the snmp id to do snmp gets:
http://www.wtcs.org/snmp4tpc/getif.htm

Sorry I don't have better information for you on the traps. I know it involved changing a few files in Nagios and then doing running sniffs on the ethernet devices to see if the traps were even coming into the system or not.
Locked