Help writing a VBScript to ping specific servers and then email results to an email address
Posted on 2007-11-19
I'm looking to write a (hopefully) simple vbscript that will output the results of a ping command to a command line mailer.
We have a number of servers that are periodically updated and then have a scheduled restart around 11pm. I'd like to schedule this new script to 'ping' a number of specified servers, return a simple 'yes' or 'no' value for each one based on whether the ping was returned, then combine these answers into a single string which I will pass to a command line emailer (BMail) as the subject. I'll then get an email at home telling me that the servers are responding after the reboots.
Now I know there are easier ways of doing this and existing free monitoring tools, but I'm keen to practise my scripting so please humour me!
So for example, there are 3 servers to test:
Assuming that Server 1 and 2 reboot fine, but 3 hangs, the output string I want will be:
SERV1: OK SERV2: OK SERV3: FAIL
I'm fine with basic vbscripting, variables, passing values to a shell command prompt etc, what I really need the help with is translating the results of a ping command into a simple yes/no answer. Is this even possible? Perhaps with error/reutrn codes? Any advice much appreciated!