Click to See Complete Forum and Search --> : need to monitor port on my PC
avenger_jcc
September 30th, 2002, 02:09 AM
Im running a specialized application on my PC that crashes quite often. I need to monitor the port it uses (4000) and when it does go down I want to automate the restart of the service.
This is on windows 2000 server...
things Ive done so far:
added it as a service
told win2000 to restart the service every time it fails (but, it doesnt detect when it stops respondingto port 4000)
Ive looked into whatsup gold, and that dont seem to poll port 4000.
any suggestions?
Syini666
September 30th, 2002, 02:52 AM
hmm, you could try comparing the firewall log against the Application Log, it could possibly give you some useful information.
Tedob1
September 30th, 2002, 06:59 AM
CHECK.BAT =
NETSTAT >THERE.TXT
FIND /C "IDENTIFYING.CHARACTERS LISTENING" there.txt >COUNT.BAT
CALL COUNT.BAT
----------------------
0.BAT =
NET SEND MYCOMPUTERNAME "The stupid program stopped again"
stupidprogram.exe
----------------------
re-direct netstat to there.txt
find /c will search the text for the the number of times the string appears.
re-direct the return to count.bat
set check.bat to go off every x number of minutes
as long as the number that gets placed in count.bat is not zero it will be trying to run an app nambed '1' as soon as '0' is the cammand that it calls it will run 0.bat which will send you a message.
you could even have 0.bat call a CSCRIPT to open the app again if thats what you want.
saint_42
September 30th, 2002, 03:18 PM
You could also use ethereal, wich is a free software that allow you to 'sniff' what's going on your network :-) If you use a port, I guess there is some communication going on, and if there is communication, there is network packets, and to sniff packets, there is http://www.ethereal.com :-)
t2k2
September 30th, 2002, 03:41 PM
One other idea is to try using portmon from the Sysinternals (http://www.sysinternals.com) site. It monitors port activity for you with a handy interface. I haven't had the chance to use it, but their other tools work pretty well. It won't send an alert or restart the service, but maybe it will help you to get an idea what's going on with the traffic to your port(s). Hope this helps...
Tedob1
September 30th, 2002, 04:40 PM
my appologies avenger_jcc.
it was pointed out to me i made a mistake.
instead of:
FIND /C "IDENTIFYING.CHARACTERS LISTENING" there.txt >COUNT.BAT
should hace been:
type there.bat |find /C "machname:4000" >count.bat
unless the file is piped threw "find" to creat count.bat the results will always include the filename first, defeating the purpose.