Page 1 of 2

Reopen (UDP port 162 is taken by sh and python)

Posted: Tue Mar 10, 2015 8:42 pm
by phyo
Hi, I want to reopen the previous case UDP port 162 is taken by sh and python. Link is here.
http://support.nagios.com/forum/viewtop ... 16&t=31105

Yesterday, I noticed some of the SNMP Traps are not updated on the nagios xi web interface even though nagios received the SNMP Traps from the remote hosts. Means with new snmptraphandling.py file, some device SNMP Traps can show on the NagiosXI web interface but some or not. So I just restore the previous snmptraphandling.py file.

Thanks.

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Wed Mar 11, 2015 11:37 am
by tmcdonald
Are there any listings in /var/log/snmptt/snmpttunknown.log?

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Wed Mar 11, 2015 12:18 pm
by questrad
As I remember I did some changes in that script based on our configuration.
If you see some of them bit dont see anothers - the script is working, it just must much following:

The host should be always in UPPERCASE.

Code: Select all

def check_arg():
        try:
                host = sys.argv[1].upper()
Also this part is changed:

Code: Select all

        try:
                if  not sys.argv[5]:
                        mondata_res = sys.argv[6]
                else:
                        mondata_res = sys.argv[6] + " / " + sys.argv[5]

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Wed Mar 11, 2015 4:29 pm
by ssax
Are you just giving us an update or are you experiencing an issue?

Sorry, it just sounds like from the second post that everything is working and you're just informing us.

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Wed Mar 11, 2015 7:38 pm
by questrad
On our Nagios configuration it working as expected.
I have just informed what kind of changes else I did in additional to handling the nagios cmd file.

If @phyo wants to handle only nagios cmd file, he can just copy and paste the part of the file handling code.

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Wed Mar 11, 2015 8:24 pm
by phyo
tmcdonald wrote:Are there any listings in /var/log/snmptt/snmpttunknown.log?
All the snmp trap go to /var/log/snmptt/snmptt.log file. Some SNMP trap can update on the web interface but some are not.

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Thu Mar 12, 2015 9:59 am
by ssax
Sorry questrad, I mistakenly thought you were OP.

phyo, did you modify the file to include the file handling code and is it working for you?

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Thu Mar 12, 2015 7:19 pm
by phyo
ssax wrote:phyo, did you modify the file to include the file handling code and is it working for you?
Change the code as "questrad" mention?

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Thu Mar 12, 2015 8:21 pm
by questrad
Take a look at the code changes that I did.
If your hosts are in upper and lower cases then you need to change following:

Code: Select all

def check_arg():
        try:
                host = sys.argv[1].upper(
To:

Code: Select all

def check_arg():
        try:
                host = sys.argv[1](
Please try this one, I think your issue is that one, because you saying that some of you get some of you dont.
Check also this log: /tmp/snmptraphandling.log if you have the SNMP from thet host that you dont see in NagiosXI.

Re: Reopen (UDP port 162 is taken by sh and python)

Posted: Fri Mar 13, 2015 11:40 am
by cmerchant
phyo, did you modify the file as questrad suggested (for the upper and lower case) and is it working for you?