Saturday, May 29, 2010

network monitor

Took me some time to find the right components, finally got it to work and this will help me a lot!

The dependencies are:
1. The mail program, best one (or only one) I found is HERE (more info and alternate download), get the one with STARTTLS (if using gmail), I saved it under %systemroot%\system32 and renamed to mail.exe for ease of use but you can leave the name (change in script) and place in same folder as script if there are security concerns.

2. Sleep command found HERE.

@echo off

SET ip=
SET wait=300

echo Checking if server (%IP%) online...
ping %IP%

if not errorlevel 1 goto :eof


echo Attempting to start VMware...
start vmware -x "D:\vmware\server\server.vmx"

echo Retry in %wait% seconds
sleep %wait%
ping %IP%

if not errorlevel 1 goto :eof

mail -f -d -smtp -port 587 -t -sub "SERVER DOWN!" -from -cc +bcc -v -starttls -auth -user USERNAME -pass PASSWORD -M "Please check server (%IP%) now!"


substitute the IP, emails, NAME and PASS to your gmail username and password.
Also which actions you want to do, if vmware check your location... etc.

Test it, and now all that's left is to schedule the script... those and more coming up in next posts.

Let me know how it goes!

No comments: