added ping logger for windows
parent
fac8ed4807
commit
97fcc59d4a
|
@ -1,2 +1,9 @@
|
|||
# short-scripts
|
||||
|
||||
Short scripts for everything
|
||||
|
||||
----
|
||||
|
||||
- Windows
|
||||
- Network
|
||||
- [ping_logger](./windows/network/ping_logger/index.md)
|
|
@ -0,0 +1,13 @@
|
|||
# Ping Logger
|
||||
|
||||
Replace the variables `check_host` & `check_hostname` from the `ping_logger.bat` like:
|
||||
```bat
|
||||
set check_host=8.8.8.8
|
||||
set check_hostname=google_dns
|
||||
```
|
||||
|
||||
You can also alter the path of the log file or name. Normally logs will be written in the `.\log` folder.
|
||||
|
||||
```bat
|
||||
set filename=.\log\%check_hostname%.log
|
||||
```
|
|
@ -0,0 +1,23 @@
|
|||
@echo off
|
||||
|
||||
|
||||
set check_host=IP
|
||||
set check_hostname=TEST
|
||||
set filename=.\log\%check_hostname%.log
|
||||
|
||||
:loop
|
||||
|
||||
set ldt=%DATE:~6,4%-%DATE:~3,2%-%DATE:~0,2% %TIME:~0,2%:%TIME:~3,2%:%TIME:~6,2%
|
||||
ping -n 1 %check_host% | find "TTL=" >nul
|
||||
if errorlevel 1 (
|
||||
echo %ldt% - ping failed %check_hostname% - %check_host%
|
||||
ECHO %ldt% - ping failed %check_hostname% - %check_host% >>%filename%
|
||||
) else (
|
||||
echo %ldt% - ping %check_hostname% - %check_host%
|
||||
)
|
||||
|
||||
@timeout /t 1 /nobreak >nul
|
||||
|
||||
goto loop
|
||||
|
||||
|
Loading…
Reference in New Issue