views:

40

answers:

3

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.

A: 

You can try to access one of its filesystem shares or ping it if you know its IP address. That would be the easiest way and both of them doable from CMD.

David Pokluda
I know the IP and I can ping as well but how would I get to know that the ping is successful?
Ritz
A: 

To check whether server is up, you can use the ping command. To send email, you can download email tools like blat etc. To repeat every 30mins, set it up using task scheduler.

ghostdog74
if ping got successful then how would I identify it?
Ritz
Does ping return some boolean value of something?
Ritz
Do a ping manually on the command line, then check its %errorlevel%.
ghostdog74
I agree with you. It worked properly.
Ritz
Can you suggest that how can I test an http request or some application server is up e.g. http ://IP:9001/
Ritz
you can use `wget` (for windows). Search google for it.
ghostdog74
A: 

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."
DMKing
Thanx a lot. Can you suggest me some way to check whether an application server is up or not. I mean checking an http request like http ://IP:9001?
Ritz
I would use wget. A nice Windows version is here http://users.ugent.be/~bpuype/wget/#download. It will return 0 on success and some other value for failure.
DMKing