UDP port 162 is taken by sh and python

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
phyo
Posts: 162
Joined: Sun Dec 01, 2013 10:50 pm

UDP port 162 is taken by sh and python

Post 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
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: UDP port 162 is taken by sh and python

Post 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>
Former Nagios employee
phyo
Posts: 162
Joined: Sun Dec 01, 2013 10:50 pm

Re: UDP port 162 is taken by sh and python

Post 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 <>?
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: UDP port 162 is taken by sh and python

Post 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.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
phyo
Posts: 162
Joined: Sun Dec 01, 2013 10:50 pm

Re: UDP port 162 is taken by sh and python

Post by phyo »

I got it. I will post again when I get the problem.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: UDP port 162 is taken by sh and python

Post 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
Former Nagios employee
phyo
Posts: 162
Joined: Sun Dec 01, 2013 10:50 pm

Re: UDP port 162 is taken by sh and python

Post by phyo »

Here is the information what you requested.

Image
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: UDP port 162 is taken by sh and python

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
phyo
Posts: 162
Joined: Sun Dec 01, 2013 10:50 pm

Re: UDP port 162 is taken by sh and python

Post 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.
questrad
Posts: 160
Joined: Wed Mar 21, 2012 3:08 pm
Location: Toronto
Contact:

Re: UDP port 162 is taken by sh and python

Post 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.
You do not have the required permissions to view the files attached to this post.
Locked