我正在制作一个批处理脚本,用于检测来自 ping 回复的高延迟并通过我的连接通知我。我的脚本通过将 ping 回复保存到日志文件来检测 300 毫秒到 700 毫秒的数字。
ping -n 15 192.206.238.4 | find /i "Reply" > nul > %cd%\acttracing.log
然后使用 findstr 搜索 300 毫秒到 700 毫秒的内容,如果这样,它将转到 :sound 并在其中播放警告通知。
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
现在的问题是,即使从保存的日志文件中找到一个高延迟数字,它也经常通知我,这显然不会影响我的连接。仅当它检测到 10 次 ERRORLEVEL 时,如何使其进入:声音?有没有办法让我的脚本比从 300 写到 700 更短?
提前致谢....