How can I continuously monitor dropped port connections using netstat and save data to a file?

121 Views Asked by At

I have a system which is integrated with other system using TCPIP connection and a specif port. Recently i am facing a multiple drop in the port establishment from the client system and i was to monitor it.

I used the command ( netstat -na | find "6565" ) but that command i need to run manually each time and what i need is to continuously run this command and to capture the date and time and to save it to a file as well. I am expecting an outcome like below:

  • 21/05/2023 13:35 TCP 10.10.5.10:6565 10.10.5.11:7575 Established
  • 21/05/2023 14:35 TCP 10.10.5.10:6565 10.10.5.11:7575 Sync_Wait
  • 21/05/2023 14:40 TCP 10.10.5.10:6565 10.10.5.11:7575 Listening

Where variables are as below:

-10.10.5.10 is the server IP

  • 6565 is the server port
  • 10.10.5.11 client IP
  • Status will be updated based on the connection status

So could anyone help my writing the correct command?

0

There are 0 best solutions below