Continuous Ping Monitor Batch File With Colour Changes: Difference between revisions
Jump to navigation
Jump to search
(Created page with "A script to continuously monitor an IP address and give clear indications when up or down with timestamp, handy for trouble shooting a network/server issues: <pre> @echo off...") |
No edit summary |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
A script to continuously monitor an IP address and give clear indications when up or down with timestamp, handy for trouble shooting a network/server issues: | A script to continuously monitor an IP address and give clear indications when up or down with timestamp, handy for trouble shooting a network/server issues. | ||
Copy and paste in Notepad and save as a batch file: | |||
<pre> | <pre> | ||
@echo off | @echo off | ||
SET OUT=0F | |||
color %OUT% | |||
mode 44,20 | mode 44,20 | ||
echo mode 44,20 | echo mode 44,20 | ||
echo off & cls | echo off & cls | ||
Title = Ping monitor | |||
set /p IP=Enter your IP Address : | set /p IP=Enter your IP Address : | ||
:top | :top | ||
set mytime=%time:~0,2%_%time:~3,2%_%time:~6,2% | set mytime=%time:~0,2%_%time:~3,2%_%time:~6,2% | ||
set mydate=%date% | set mydate=%date% | ||
PING -n 1 %IP% | FIND "TTL=" >nul | PING -n 1 %IP% | FIND "TTL=" >nul | ||
IF ERRORLEVEL 1 (SET OUT=4F & echo %mydate% : %time:~0,2%:%time:~3,2%:%time:~6,2%% : Down) ELSE (SET OUT=2F & echo %mydate% : %time:~0,2%:%time:~3,2%:%time:~6,2%% Up) | IF ERRORLEVEL 1 (SET OUT=4F & echo %mydate% : %time:~0,2%:%time:~3,2%:%time:~6,2%% : Down & Title Down %IP%) ELSE (SET OUT=2F & echo %mydate% : %time:~0,2%:%time:~3,2%:%time:~6,2%% : Up & Title Up %IP%) | ||
color %OUT% | color %OUT% | ||
ping -n 2 -l 10 127.0.0.1 >nul | ping -n 2 -l 10 127.0.0.1 >nul | ||
Line 18: | Line 24: | ||
Examples: | Examples: | ||
[[File:ping.jpg]] | |||
[[Category:DOS]] | |||
[[Category:ping]] | |||
[[Category:batch file]] | |||
<comments /> |
Latest revision as of 09:03, 20 March 2022
A script to continuously monitor an IP address and give clear indications when up or down with timestamp, handy for trouble shooting a network/server issues.
Copy and paste in Notepad and save as a batch file:
@echo off SET OUT=0F color %OUT% mode 44,20 echo mode 44,20 echo off & cls Title = Ping monitor set /p IP=Enter your IP Address : :top set mytime=%time:~0,2%_%time:~3,2%_%time:~6,2% set mydate=%date% PING -n 1 %IP% | FIND "TTL=" >nul IF ERRORLEVEL 1 (SET OUT=4F & echo %mydate% : %time:~0,2%:%time:~3,2%:%time:~6,2%% : Down & Title Down %IP%) ELSE (SET OUT=2F & echo %mydate% : %time:~0,2%:%time:~3,2%:%time:~6,2%% : Up & Title Up %IP%) color %OUT% ping -n 2 -l 10 127.0.0.1 >nul GoTo top
Examples: