Page 1 of 1

SNMP Traps Not Triggering In NagiosXI (Bug?)

Posted: Wed Dec 21, 2011 1:53 pm
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

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

Posted: Wed Dec 21, 2011 2:23 pm
by agriffin
Thanks, I will pass this information along to our developer working on this!

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

Posted: Wed Dec 21, 2011 3:33 pm
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.

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

Posted: Wed Dec 21, 2011 4:07 pm
by agriffin
I edited your post to put the code between tags, so it shows indentation now.

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

Posted: Wed Dec 21, 2011 4:22 pm
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.