SNMP Traps Not Triggering In NagiosXI (Bug?)

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
bvinisky
Posts: 34
Joined: Wed Jul 06, 2011 11:28 am

SNMP Traps Not Triggering In NagiosXI (Bug?)

Post by bvinisky »

Hello,

1. RHEL 6.1
2. 32bit
3. Manual Install of XI
4. No special configurations

I ran into an issue with SNMP Trap handling in NagiosXI that I thought I'd share. I followed the documentation on SNMP trap setup to a T, but NagiosXI was never aware of any trap messages that came in. The trap messages were showing up in the snmptt.log without issue. I tracked the problem back to /usr/local/bin/snmptraphandling.py, since this is what was executing when a trap message came in. When testing this command manually, it was failing with...

Code: Select all

File "/usr/local/bin/snmptraphandling.py", line 46
    if severity == "INFORMATIONAL":
                                                  ^
IndentationError: unindent does not match any outer indentation level
I know almost nothing about Python, but based off of the error message I did notice that the indentation was a little funny in one of the declarations. It looked like this:

Code: Select all

def get_return_code(severity):
                   severity = severity.upper()
        if severity == "INFORMATIONAL":
                return_code = "0"
        elif severity == "NORMAL":
                return_code = "0"
        elif severity == "SEVERE":
                return_code = "2"
        elif severity == "MAJOR":
                return_code = "2"
        elif severity == "CRITICAL":
                return_code = "2"
        elif severity == "WARNING":
                return_code = "1"
        elif severity == "MINOR":
                return_code = "1"
        else:
                printusage()
        return return_code
Once I un-indented the 'severity' statement so it was even with the if statements, everything worked as expected.

- Bryant
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: SNMP Traps Not Triggering In NagiosXI (Bug?)

Post by agriffin »

Thanks, I will pass this information along to our developer working on this!
bvinisky
Posts: 34
Joined: Wed Jul 06, 2011 11:28 am

Re: SNMP Traps Not Triggering In NagiosXI (Bug?)

Post by bvinisky »

I'm sure you get what I meant, but after seeing that the post didn't have the indentations... "severity = severity.upper()" was indented further to the right than the statements that followed were.
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: SNMP Traps Not Triggering In NagiosXI (Bug?)

Post by agriffin »

I edited your post to put the code between tags, so it shows indentation now.
User avatar
nscott
Posts: 1040
Joined: Wed May 11, 2011 8:54 am

Re: SNMP Traps Not Triggering In NagiosXI (Bug?)

Post by nscott »

Yeah, thats all you'll have to do. I've fixed that same problem before in that exact same spot. Seems like the change gets rolled back. But for your problem, that is exactly the fix. I'm going to look into why that file gets changed on our end.
Nicholas Scott
Former Nagios employee
Locked