-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15a57a3
commit 6539ccf
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## Ping Logger | ||
- a script for logging ping results in a txt file in order to be able to determine ping times for a ping target over a longer period of time. | ||
- everything else that can be set (e.g. ping target, wait time, end time for the script run, etc.) can be set as variables in the script. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
@echo off | ||
setlocal enabledelayedexpansion | ||
|
||
REM destination address for the ping | ||
set target=192.168.178.1 | ||
|
||
REM log file | ||
set logfile=%target%-ping_log.txt | ||
|
||
REM Waiting time in seconds | ||
set waittime=1 | ||
|
||
REM End time (in format HH:MM), leave blank for infinite running | ||
set endtime= | ||
|
||
REM Current time | ||
for /f "tokens=1-2 delims=:" %%a in ("%time%") do set currenttime=%%a:%%b | ||
|
||
REM Set the beginning of the log file | ||
echo -------------------------------------------------- | ||
echo !date! !time! - Starte Ping_Logger für Target: %target% | ||
echo -------------------------------------------------- | ||
echo -------------------------------------------------- >> %logfile% | ||
echo !date! !time! - Starte Ping_Logger für Target: %target% >> %logfile% | ||
echo -------------------------------------------------- >> %logfile% | ||
|
||
REM ping loop | ||
:pingloop | ||
for /f "tokens=1-2 delims=:" %%a in ("%time%") do set currenttime=%%a:%%b | ||
if defined endtime if "!currenttime!" geq "%endtime%" goto end | ||
|
||
REM Ping command and logging the result | ||
for /f "tokens=4-5 delims= " %%a in ('ping -n 1 %target% ^| find "Zeit="') do ( | ||
set pingtime=%%b | ||
echo !date! !time! - %target% ist erreichbar - !pingtime! | ||
echo !date! !time! - %target% ist erreichbar - !pingtime! >> %logfile% | ||
) | ||
|
||
REM waiting time | ||
timeout /t %waittime% >nul | ||
|
||
goto pingloop | ||
|
||
:end | ||
echo Ping script terminated. |