Solve Tutorial 1

This commit is contained in:
Manuel Thalmann 2023-10-04 20:30:44 +02:00
parent f2576d85e7
commit a26eef343d
2 changed files with 36 additions and 0 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
# Log files
*.log

View file

@ -0,0 +1,34 @@
IF NOT EXIST uptime.log (
echo Host;Date;Time;Result > stats.log
)
IF NOT EXIST stats.log (
echo 0 0 0 > stats.log;
)
FOR /F "tokens=1,2,3 delims= " %%i in (stats.log) do (
SET TOTAL=%%j
SET FAILS=%%j
SET FAILSINROW=%%k
)
echo "Total: %TOTAL%";
echo "Fails: %FAILS%";
echo "FIR: %FAILSINROW%";
ping 8.8.8.255
if errorlevel 1 (
set RESULT=fail
set /a FAILS+=1
set /a FAILSINROW+=1
) else (
set RESULT=OK
set FAILSINROW=0
)
set /a TOTAL+=1
echo %TOTAL% %FAILS% %FAILSINROW% > stats.log
echo %computername%;%date%;%time%;%RESULT% >> uptime.log
if %FAILSINROW%==3 msg * alert! lets go home