I am making a batch script that detects High latency from a pinging reply and to notify me with my connection. My script detects 300ms to 700ms numbers by saving pinging reply to log file.
ping -n 15 192.206.238.4 | find /i "Reply" > nul > %cd%\acttracing.log
Then use findstr to search for 300ms to 700ms content and if thus it will go to :sound where it plays a warning notification.
nul findstr /c:"time=680" acttracing.log && (
echo "High Latency" was found.
) || (
echo "High Latency" was NOT found.
)
If %ERRORLEVEL% equ 0 goto :sound
nul findstr /c:"time=685" acttracing.log && (
echo "High Latency" was found.
) || (
echo "High Latency" was NOT found.
)
If %ERRORLEVEL% equ 0 goto :sound
nul findstr /c:"time=690" acttracing.log && (
echo "High Latency" was found.
) || (
echo "High Latency" was NOT found.
)
If %ERRORLEVEL% equ 0 goto :sound
nul findstr /c:"time=695" acttracing.log && (
echo "High Latency" was found.
) || (
echo "High Latency" was NOT found.
)
If %ERRORLEVEL% equ 0 goto :sound
nul findstr /c:"time=700" acttracing.log && (
echo "High Latency" was found.
) || (
echo "High Latency" was NOT found.
)
If %ERRORLEVEL% equ 0 goto :sound
Now the problem, it's frequently notifying me even in one high latency number found from the saved log file which obviously not affecting my connection. How to make it go to :sound only if it detects 10 times ERRORLEVEL? is there a way to write my script shorter than writing it from 300 to 700?
thanks in advance....