I need to check whether a server is up or not? If down then i need to send an email And this task should be repeated in every 30mins.
I have to do this using batch file.
At the command line, type in net statistics for a list of core performance data, such as network errors, hung sessions, bytes received, SMBs received/transmitted, write/read errors, etc. This includes all data since the last reboot—oh, and that also gives you the server's uptime!
[ == ] (Double Equals) The "IF" command uses this to test if two strings are equal: IF "%1" == "" GOTO HELP. means that if the first parameter on the command line after the batch file name is equal to nothing, that is, if a first parameter is not given, the batch file is to go to the HELP label.
Windows has always used the Services panel as a way to manage the services that are running on your computer. You can easily get there at any point by simply hitting WIN + R on your keyboard to open the Run dialog, and typing in services. msc.
This batch file will get you most of the way there. You'll have to use blat or something similar or Windows script to send the email. Use the task scheduler to call the batch file every 30 minutes.
checkserver.bat:
@echo off
ping -n 1 %1 > NUL
IF ERRORLEVEL 0 (echo "Up -- Don't send email.") ELSE echo "Down -- Send email."
Call it like so:
C:\>checkserver 127.0.0.1
"Up -- Don't send email."
C:\>checkserver 128.0.0.1
"Down -- Send email."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With