Monitor tcp connection on Window client

Hi all,

I need to monitor if a Windows client has a active connection to a specific service (tcp port) on a remote server and if not I want to use the Dude to restart a service on that client.
Does anybody have a input regarding how to do that.

TIA

Best regards
Lennart

lelle,
It seems that we may try to use the following algorithm:

  1. Get list of connections on Windows Client.
  2. Identify if exist a required connection is in ESTABLISHED state.
  3. Verify if this connection it started by required application.
  4. If p.3 not true - restart required service.

1., 2. Get list of connections in ESTABLISHED state:

netstat -o -n -b | find /I "192.168.1.1:443" | find /I "ESTABLISHED"

Will return us similar output:
TCP 192.168.1.2:34766 192.168.1.1:443 ESTABLISHED 2176
Where last number is process PID.
3. Will verify if this PID is our application:

tasklist /FI "PID eq 2176" | find /I "explorer.exe"
  1. Restart service
net stop myservice
net start myservice

We may use PsExec to get information or restart service on remote system.
An example as a start point: http://forum.mikrotik.com/t/problem-with-mount-point/94/1

Thank you!