Link to home
Start Free TrialLog in
Avatar of rharivenkatesh
rharivenkatesh

asked on

Port Monitoring using Shell Script

Hello Gurus,

Can someone tell me how to do Port Monitoring using Shell Script? I am planning to write a code to monitor an instance running using Port Monitorig. How to do that and find out the state?

Thanks in Advance.

Regards.
Hari.
Avatar of peter991
peter991
Flag of Sweden image

snoop could do the trick.
"man snoop"
$>netstat -an
will give you the state and more.
Avatar of omarfarid
what type of ports? each port means one type of protocol. There are tools for some protocols that can be used to monitor.
ASKER CERTIFIED SOLUTION
Avatar of awa2008
awa2008

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You have a few answers here, but the real problem is that you haven't really told us what you need here. What kind of ports do you mean, and what kind of monitoring?  You want to stay away from lsof on Solaris if possible. It uses a lot of resources to get its info and it uses private interfaces in the kernel and so can stop working with the application of a patch.  Netstat might do what you want or even kstats. It depends on the answer to the first question.
Avatar of rharivenkatesh
rharivenkatesh

ASKER

Basically we have applications running instances. These applications run in the application port something lie 27810. We do monitor the application process in Unix but we would also like to monitor the port if there is any activity. By checking the process running we cannot find out if it is hanging.

All are TCP application ports that are used to run our application instances in Websphere 6.0

Regards.
Hari.
if it is not a standard application (e.g. http) then you need to write your own tool that will interact with the application over that port and send / receive some data.

you can do this with telnet and expect if the protocol / application exchange simple text
If the problem you are trying to diagnose is a hang, then you need to make sure that there is a "null" function in your application, and then periodically call this "null" function to verify proper functioning of the application.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Peter,

Could you please let me know where would this "snoop" binary executable present? Is it in /usr/bin? I am not able to run in my Solaris system. When i type "snoop" it says "not found" or does it come as a separate package? Or is it something like only a Administrators can run?

Regards.
Hari.

# which snoop
/usr/sbin/snoop

regards
It does not answer completely on the requirement.