Jump to content

How To Check If A Server Is Up?


Recommended Posts

Hi!

I am very new to AutoIt, but not new to scripting (specifically, WinBatch) and programming. AutoIt looks like a very interesting scripting app. Seems quite powerful and the price is great! ;-)

One thing I would like to do is to create a simple app that will ping a server (or list of servers) and display a "status" based on if the server was reachable. This can be very easily done using WinBatch, but I no longer have access to WinBatch, so I am looking for another scripting solution that would allow me to do this.

Basically, I would like to return to the program successes or non-successes of pinging. Once I have that, it should be simple to "make it pretty" with some GUI stuff.

I have looked in the help file and looked over the functions list, but don't seem to find anything that would let me execute a 'ping' and return a status.

Any hints or suggestions?

Thanks!

-Jim

Visit Jim's Tips for lots of cool tips on Gmail, SageTV, PDA's, and whatever else interests me!

Link to comment
Share on other sites

OK, I figured it out!

It's a bit kludgy, but it works. Here's what I did...

First, I created a list of servers that I want to "ping". I then used the "_RunDOS" command to execute a "ping" command in the background for each server routing the output to a temporary file. I then simply parsed the temporary file looking for a specific string of text that would indicate a successful ping. From this, I build a status string that will later be displayed based on the existance of that string. I repeat this for each host that I have listed, and when finished, the result is a message box listing the hosts and their statuses.

The source file can be found here:

http://jim.barr.net/files/HostPingStatus.zip

See the documentation in the .au3 file for details on how to use it and what features and improvements I'll be making.

A few caveats:

1. You MUST follow the instructions in the documentation to configure it to your needs.

2. This only "pings" the host. It doesn't check services or anything else. It just checks to see if the host is reachable.

3. Depending on what version of Windows you are using, the "ping" command may or may not return the same string. I tested this on Windows XP Pro, and it works fine for me.

4. If your hosts are not normally reachable by the "ping" command, this will obviously not work.

This is fun!

-Jim

http://jim.barr.net

http://jimstips.com

Visit Jim's Tips for lots of cool tips on Gmail, SageTV, PDA's, and whatever else interests me!

Link to comment
Share on other sites

Oooo. Nice! Basically what I'm doing, but a bit tighter and cleaner. Good to see I'm at least on the right track!

My only real issue now is to figure out the best way to display everything:

If I use a "MsgBox" then it requires user input and won't auto-refresh. And the fonts are set.

If I use a "SplashText" function, I can nicely set a font, and it will auto-refresh nicely, but it doesn't seem to provide for any user interaction (short of terminating the app from the System Tray or moving the window.)

It would be nice to at least have the "standard" GUI controls on the window (Minimize, Restore/Full, Close) but it is workable.

Maybe I'll investigate some of the GUI extensions available...

Visit Jim's Tips for lots of cool tips on Gmail, SageTV, PDA's, and whatever else interests me!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...