@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET IP[1]=203.158.101.100=user_xx@gmail.com
SET IP[2]=8.8.8.8=user_xx@gmail.com
SET TimeBetweenPings=5
SET RetryBeforeEmail=5
REM SETTING FLAGS
FOR /F "tokens=2 delims==" %%A IN ('SET IP[') DO (
SET AlertFlag[%%A]=0
SET AlertSentGood[%%A]=1
)
:Home
CLS
REM PINGING DESTINATIONS
ECHO ERR EML TARGET IP ADDRESS
ECHO -------------------------
FOR /F "tokens=2,3 delims==" %%A IN ('SET IP[') DO (
ECHO [!AlertFlag[%%A]!] [!AlertSentGood[%%A]!] [%%A]
PING -n 1 %%A >NUL
IF !errorlevel! == 0 (
SET AlertFlag[%%A]=0
IF "!AlertSentGood[%%A]!" == "0" (
CALL :EMAIL "%%A Resolved" "%%B"
SET AlertSentGood[%%A]=1
)
) ELSE (
SET /a AlertFlag[%%A]+=1
)
IF !AlertFlag[%%A]! == %RetryBeforeEmail% (
CALL :EMAIL "%%A ERROR ALERT" "%%B"
SET AlertSentGood[%%A]=0
)
)
PING -n %TimeBetweenPings% -w 1000 10.0.0.0>NUL
Goto Home
:EMAIL
ECHO SENDING EMAIL
REM PUT BLAT COMMAND HERE
EXIT /b
โค๊ดนี้อ่ะค่ะ อยากทราบว่าแต่ละบรรรทัดทำอะไรบ้างเท่านั้นค่ะ ขอบคุณล่วงหน้าค่ะ
รบกวนผู้รู้ช่วยค่ะ ไม่เข้าใจจริงๆอธิบายโค๊ดให้หน่อยค่ะ
SETLOCAL EnableDelayedExpansion
SET IP[1]=203.158.101.100=user_xx@gmail.com
SET IP[2]=8.8.8.8=user_xx@gmail.com
SET TimeBetweenPings=5
SET RetryBeforeEmail=5
REM SETTING FLAGS
FOR /F "tokens=2 delims==" %%A IN ('SET IP[') DO (
SET AlertFlag[%%A]=0
SET AlertSentGood[%%A]=1
)
:Home
CLS
REM PINGING DESTINATIONS
ECHO ERR EML TARGET IP ADDRESS
ECHO -------------------------
FOR /F "tokens=2,3 delims==" %%A IN ('SET IP[') DO (
ECHO [!AlertFlag[%%A]!] [!AlertSentGood[%%A]!] [%%A]
PING -n 1 %%A >NUL
IF !errorlevel! == 0 (
SET AlertFlag[%%A]=0
IF "!AlertSentGood[%%A]!" == "0" (
CALL :EMAIL "%%A Resolved" "%%B"
SET AlertSentGood[%%A]=1
)
) ELSE (
SET /a AlertFlag[%%A]+=1
)
IF !AlertFlag[%%A]! == %RetryBeforeEmail% (
CALL :EMAIL "%%A ERROR ALERT" "%%B"
SET AlertSentGood[%%A]=0
)
)
PING -n %TimeBetweenPings% -w 1000 10.0.0.0>NUL
Goto Home
:EMAIL
ECHO SENDING EMAIL
REM PUT BLAT COMMAND HERE
EXIT /b
โค๊ดนี้อ่ะค่ะ อยากทราบว่าแต่ละบรรรทัดทำอะไรบ้างเท่านั้นค่ะ ขอบคุณล่วงหน้าค่ะ