Skip to content

Commit

Permalink
Add Ping Logger Script
Browse files Browse the repository at this point in the history
  • Loading branch information
LizenzFass78851 authored Dec 12, 2024
1 parent 15a57a3 commit 6539ccf
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Ping Logger/README.md
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.
45 changes: 45 additions & 0 deletions Ping Logger/ping_logger.bat
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.

0 comments on commit 6539ccf

Please sign in to comment.