PING failed send alert email

If ping to a device failed send an alert e-mail

Pokud není ping na zařízení, pošli oznámení

ping.cmd:

@echo off
ping 192.168.0.1 > c:\temp\pinglog.txt
find “TTL=” < c:\temp\pinglog.txt
if not errorlevel 1 goto :END
call C:\alert.vbs
:END

REM Most programmers agree that an errorlevel 0 means the command executed succesfully, and an errorlevel 1 or higher usually spells trouble

______________________________

alert.vbs:

Set objEmail = CreateObject(“CDO.Message”)
objEmail.From = “mejl@mejl.cz”
objEmail.To = “alert@mejl.cz”
objEmail.Subject = “device is DOWN #WARNING#”
objEmail.Textbody = “device is DOWN #WARNING# – ALERT value —  There is no packet TTL”
objEmail.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/sendusing&#8221;) = 2
objEmail.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserver&#8221;) = _
“yourSMTP.local”
objEmail.Configuration.Fields.Item _
(“http://schemas.microsoft.com/cdo/configuration/smtpserverport&#8221;) = 25
objEmail.Configuration.Fields.Update
objEmail.Send

Advertisements