Skip to content

Instantly share code, notes, and snippets.

@dotmanila
Created July 24, 2012 04:08
Show Gist options
  • Save dotmanila/3167982 to your computer and use it in GitHub Desktop.
Save dotmanila/3167982 to your computer and use it in GitHub Desktop.
Monitor for SYNC_RECV and trigger netstat and wget in Windows
@echo off
:xloop
for /f "delims=" %%a in ('netstat -ant^|find /v "ESTABLISHED"^|find /v "TIME_WAIT"^|find /v /c "LISTENING"') do set c=%%a
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c-%%a-%%b)
for /f "tokens=1,2,3 delims=/:" %%a in ("%TIME: =0%") do (set mytime=%%a%%b%%c)
set ntfil=%mydate%_%mytime%
echo %ntfil% Found %c% connections
if %c% GTR 100 (
echo ... triggered
.\wget-1.11.4-1-bin\bin\wget.exe -q -T 30 -O "server-status-%ntfil%.html" http://10.10.60.103:10000/server-status
netstat -ant > "netstat-%ntfil%.txt"
echo Sleeping for 10 seconds ...
)
ping localhost -n 11 > nul
goto xloop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment