Page 1 of 3

UDP port 162 is taken by sh and python

Posted: Mon Jan 26, 2015 9:03 pm
by phyo
Yesterday, my customer found out SNMP Traps service is not receiving new SNMP traps since 4 days ago(22 Jan 2015).
When I checked the UDP port 162 status, sh, snmptt and python are using UDP 162 also. After killing the sh and python process and restart the snmptt and snmptrapd service, SNMP Traps is come back.

Why sh,snmptt and python are also using the UDP port 162? Can we prevent this?

Please see the below picture to get more information what i did.
Image
Image

Re: UDP port 162 is taken by sh and python

Posted: Tue Jan 27, 2015 11:35 am
by tmcdonald
Typically if a process is listening on a port it will say (LISTEN) at the end.

Can you check what those PIDs are next time? Something like this will show you:

Code: Select all

ps -ef | grep <pid>

Re: UDP port 162 is taken by sh and python

Posted: Wed Jan 28, 2015 8:59 pm
by phyo
tmcdonald wrote:Typically if a process is listening on a port it will say (LISTEN) at the end.
Can you check what those PIDs are next time? Something like this will show you:

Code: Select all

ps -ef | grep <pid>
You would like to know the PID of sh,snmptt and python?
what about your command?
ps -ef | grep <pid> what should i type in the <>?

Re: UDP port 162 is taken by sh and python

Posted: Wed Jan 28, 2015 9:17 pm
by Box293
In your screenshot it says:

snmptrapd (pid 2202) is running...

Then in your lfos command, the output has:
snamptrapd 2022
sh 20960
snmptt 20961
python 20964

So the next time you get the problem, run the lsof command to determine the pid's and then run that command for each of those pid's.

Re: UDP port 162 is taken by sh and python

Posted: Wed Jan 28, 2015 9:54 pm
by phyo
I got it. I will post again when I get the problem.

Re: UDP port 162 is taken by sh and python

Posted: Thu Jan 29, 2015 10:13 am
by tmcdonald
And to be clear, the <brackets> are to be replaced and omitted for the actual command. For example, if the PID is 1234, you would run:

Code: Select all

ps -ef | grep 1234

Re: UDP port 162 is taken by sh and python

Posted: Wed Feb 11, 2015 8:30 pm
by phyo
Here is the information what you requested.

Image

Re: UDP port 162 is taken by sh and python

Posted: Thu Feb 12, 2015 10:13 am
by tgriep
Those services and python scripts are needed for receiving SNMP traps on the Nagios server and they are used to process them and something is holding the process from finishing.

Can you upload the following log files to this post so we can debug this issue?

Code: Select all

/var/log/snmptt/snmptt.log
/var/log/snmptt/snmpttsystem.log
/var/log/snmptt/snmpttunknown.log

Re: UDP port 162 is taken by sh and python

Posted: Fri Feb 13, 2015 1:43 am
by phyo
tgriep wrote:Those services and python scripts are needed for receiving SNMP traps on the Nagios server and they are used to process them and something is holding the process from finishing.

Can you upload the following log files to this post so we can debug this issue?

Code: Select all

/var/log/snmptt/snmptt.log
/var/log/snmptt/snmpttsystem.log
/var/log/snmptt/snmpttunknown.log
Here is the file that you requested.
https://dl.dropboxusercontent.com/u/228 ... /snmptt.7z

I also copy snmpttsystem.log old file (snmpttsystem.log-20150118) also because there is nothing in the snmpttsystem.log file.

Re: UDP port 162 is taken by sh and python

Posted: Fri Feb 13, 2015 3:26 am
by questrad
Question - that 4 days ago, did you restart your Nagios XI?
I mean did you stop everything and started it again?
If yes - then there is bug in snmptraphandling, which tries to write in to cmd file (pipe file) but file is not exist any more when you stop the nagios and python is stuck on that step.
Attached is my modified trap handler python script.