Below is the batch file I am currently using, but I would like to chage it so that it is not just green if the link is good and red if it times out. I would like it to turn yellow if response is not within a particular range. So if my RTT range is not within 130-190 ms it would turn yellow. Thanks in advance
I want the screen to be green if it falls in a range, yellow if it falls out of the range, and red it the request times out.
echo off & cls
TITLE = Test
:top
ping -n 1 8.8.8.8 | FIND "TTL="
IF ERRORLEVEL 1 (SET OUT=4F & echo Request timed out.) ELSE (SET OUT=2F)
color %OUT%
ping -n 3 -w 1000 127.0.0.1 >nul
GoTo top
edited to adapt to comments
It just repeat an infinite loop checking the indicated address (readed from command line in this code).
In each iteration it is determined the current rtt from the ping command, the color selected according to the rtt and the information echoed to console with the colors changed.
To get the rtt, a ping is executed. If the host is active it will be a
TTL=
string in the output. If the line is found, it is tokenized using the characters=<
as delimiters to get the third token (where the rtt is located) and then them
fromms
is used to separate the numeric value of the rtt.With the rtt time, the values (the pair level:color) in the list of levels is iterated. For each value, the level and color are separated and the level tested agains the rtt. If the rtt is greater or equal to the level, we have found the adecuated color.
Color is changed, information printed and the code waits before starting a new iteration