Solve Tutorial 1
This commit is contained in:
parent
f2576d85e7
commit
a26eef343d
2 changed files with 36 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Log files
|
||||
*.log
|
34
Tutorial 1 - CMD Scripting/checkUptime.cmd
Normal file
34
Tutorial 1 - CMD Scripting/checkUptime.cmd
Normal 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
|
Loading…
Reference in a new issue