snmptt and Nagios

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
rseiwert
Posts: 196
Joined: Wed Jun 22, 2011 10:33 pm
Location: Somewhere between Here and Now

snmptt and Nagios

Post by rseiwert »

I setup as per the document but having issues getting traps to appear in Nagios.
In the snmptt.log
Thu Oct 6 15:04:01 2011 .1.3.6.1.4.1.318.0.80 WARNING "Status Events" nj_demark_ups - APC UPS: No batteries attached.: The UPS has no batteries attached.
Thu Oct 6 15:14:02 2011 .1.3.6.1.4.1.318.0.80 WARNING "Status Events" nj_demark_ups - APC UPS: No batteries attached.: The UPS has no batteries attached.
Thu Oct 6 15:21:22 2011 .1.3.6.1.4.1.318.0.47 WARNING "Status Events" nj_demark_ups - APC: Access violation via HTTP.: An unsuccessful attempt to login via HTTP.

but in Nagios I have:
SNMP Traps
On Host
NJ_Demark_UPS
(nj_demark_ups)
Service State Information
Current Status: OK (for 0d 0h 4m 58s)
Status Information: Waiting for trap...
Performance Data:
Current Attempt: 1/1 (HARD state)
Last Check Time: 10-06-2011 15:20:09
Check Type: PASSIVE
Check Latency / Duration: N/A / 0.000 seconds
Next Scheduled Check: N/A
Last State Change: 10-06-2011 15:20:09
Last Notification: N/A (notification 0)
Is This Service Flapping? N/A
In Scheduled Downtime? NO
Last Update: 10-06-2011 15:24:59 ( 0d 0h 0m 8s ago)
Last edited by rseiwert on Fri Oct 07, 2011 11:01 am, edited 1 time in total.
Grumpy Olde IT Guy
User avatar
rseiwert
Posts: 196
Joined: Wed Jun 22, 2011 10:33 pm
Location: Somewhere between Here and Now

Re: snmptt and Nagios

Post by rseiwert »

Is hostname matching case sensitive with the snmp trap wizard? I previously had a FQDN as the hostname in Nagios plus caps in the name. I made everything match by removing the domain and matching the case.

*** Yes it is case-sensitive ***
Last edited by rseiwert on Sat Oct 08, 2011 11:44 pm, edited 2 times in total.
Grumpy Olde IT Guy
User avatar
rseiwert
Posts: 196
Joined: Wed Jun 22, 2011 10:33 pm
Location: Somewhere between Here and Now

Re: snmptt and Nagios

Post by rseiwert »

ok I was wrong. I came back for lunch and had an informational message in Nagios. Thought it was working but I generated some traps and nothing changes in Nagios. SnmpTT gets it but it doesn't show up in Nagios. I thought this should show up fairly quickly.

Thu Oct 6 16:40:59 2011 .1.3.6.1.4.1.318.0.81 INFORMATIONAL "Status Events" nj_demark_ups - APC UPS: The no batteries attached condition has been cleared.: The UPS's batteries have been attached.
Thu Oct 6 16:48:02 2011 .1.3.6.1.4.1.318.0.47 WARNING "Status Events" nj_demark_ups - APC: Access violation via HTTP.: An unsuccessful attempt to login via HTTP.
Thu Oct 6 17:06:49 2011 .1.3.6.1.4.1.318.0.47 WARNING "Status Events" nj_demark_ups - APC: Access violation via HTTP.: An unsuccessful attempt to login via HTTP.

Advanced Status Details
Service State: Ok
Duration: 1h 53m 55s
State Type: Hard
Current Check: 1 of 1
Last Check: 2011-10-06 16:40:59
Next Check: Not scheduled
Last State Change: 2011-10-06 15:20:09
Last Notification: Never
Check Type: Passive
Check Latency: 0.64442 seconds
Execution Time: 0 seconds
State Change: 0%
Grumpy Olde IT Guy
User avatar
rseiwert
Posts: 196
Joined: Wed Jun 22, 2011 10:33 pm
Location: Somewhere between Here and Now

Re: snmptt and Nagios

Post by rseiwert »

At this point I would like to buy a clue.

At this point I have gone thru the library document setting up SNMP Traps twice, I read thru the installer, checked a few things. Read thru the snmptt trap handler, seems basic but I don't understand why I don't see alerts in Nagios. Maybe some debouncing logic in the process pipe nagios.cmd?

From the SnmpTT.log
Thu Oct 6 18:03:51 2011 .1.3.6.1.4.1.318.0.80 WARNING "Status Events" nj_demark_ups - APC UPS: No batteries attached.: The UPS has no batteries attached.
Thu Oct 6 18:16:28 2011 .1.3.6.1.6.3.1.1.5.1 Normal "Status Events" nj_demark_ups - A coldStart trap signifies that the SNMP entity, APC Web/SNMP Management Card
Thu Oct 6 18:16:32 2011 .1.3.6.1.4.1.318.0.80 WARNING "Status Events" nj_demark_ups - APC UPS: No batteries attached.: The UPS has no batteries attached.
Thu Oct 6 18:16:32 2011 .1.3.6.1.4.1.318.0.3 SEVERE "Status Events" nj_demark_ups - APC UPS: Failed self-test: The UPS has failed its internal self-test.
Thu Oct 6 18:16:34 2011 .1.3.6.1.4.1.318.0.12 WARNING "Status Events" nj_demark_ups - APC UPS: Turned off: The UPS has been switched off by a management station.

But in Nagios.log
[1317913585] SERVICE ALERT: NJ_Demark_UPS;SNMP Traps;OK;HARD;1;Waiting for trap...
[1317928819] SERVICE ALERT: nj_demark_ups;SNMP Traps;OK;HARD;1;Waiting for trap...
[1317931689] SERVICE ALERT: nj_demark_ups;SNMP Traps;OK;HARD;1;APC UPS: The no batteries attached condition has been cleared.: The UPS's batteries have been attached. / enterprises.318.2.3.3.0 ():UPS: No batteries installed cleared.
[1317939399] SERVICE ALERT: nj_demark_ups;SNMP Traps;OK;HARD;1;A coldStart trap signifies that the SNMP entity, APC Web/SNMP Management Card / sysDescr.0 (OCTETSTR):APC Web/SNMP Management Card
Grumpy Olde IT Guy
User avatar
rseiwert
Posts: 196
Joined: Wed Jun 22, 2011 10:33 pm
Location: Somewhere between Here and Now

Re: snmptt and Nagios

Post by rseiwert »

This is a bug in /usr/local/bin/snmptraphandling.py. I made the status compares case insensitive. I also closed the file handle for good measure.

Code: Select all

def get_return_code(severity):
        if severity.upper() == "INFORMATIONAL":
                return_code = "0"
        elif severity.upper() == "NORMAL":
                return_code = "0"
        elif severity.upper() == "SEVERE":
                return_code = "2"
        elif severity.upper() == "MAJOR":
                return_code = "2"
        elif severity.upper() == "CRITICAL":
                return_code = "2"
        elif severity.upper() == "WARNING":
                return_code = "1"
        elif severity.upper() == "MINOR":
                return_code = "1"
        else:
                printusage()
        return return_code


def post_results(host, service, mytime, mondata_res, return_code):
        output = open('/usr/local/nagios/var/rw/nagios.cmd', 'w')
        results = "[" + mytime + "] " + "PROCESS_SERVICE_CHECK_RESULT;" \
            + host + ";" + service + ";" \
            + return_code + ";" + mondata_res + "\n"
        output.write(results)
        output.close()


Grumpy Olde IT Guy
User avatar
nscott
Posts: 1040
Joined: Wed May 11, 2011 8:54 am

Re: snmptt and Nagios

Post by nscott »

rseiwert I was just reading through the thread, nice detective work.

Did your fix to the python script fix your issue?
Nicholas Scott
Former Nagios employee
User avatar
rseiwert
Posts: 196
Joined: Wed Jun 22, 2011 10:33 pm
Location: Somewhere between Here and Now

Re: snmptt and Nagios

Post by rseiwert »

Yes it did. I see traps other than "Normal" now. Now all I need to know is how to clear these alerts.
Grumpy Olde IT Guy
User avatar
nscott
Posts: 1040
Joined: Wed May 11, 2011 8:54 am

Re: snmptt and Nagios

Post by nscott »

Thanks for pointing out the bug. I've fixed it in our source.
Nicholas Scott
Former Nagios employee
Locked