Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm using WhatsUpGold to monitor the uptime of services and one of them is a MySql server. Since there's no explicit support for MySql, I'm forced to write a VBS script to do it. Unfortunately, WhatsUpGold doesn't support WScript.Sleep. The alternative that is on their forum is this one but it seems like a dirty hack. Are there any alternatives to the two of these that I can use? I'd really prefer not to have to copy/paste functions around.

share|improve this question

5 Answers 5

Ooh, now that is a hacky trick. It'll work though, if the user the app is running as isn't locked down such that it can't use wshell.run. I think I actually like it...

If the app is running on a box that you have admin access to so that you can register a COM DLL, then when I want a sleep in classic ASP code for testing (it is sometimes useful to insert artificial delays) I use a simple free DLL that is unfortunately not longer available from the original source (see here for some discussion). If you want to give it a try I've put a copy in here. To invoke, use something like Dim WaitObj: Set WaitObj = Server.CreateObject ("WaitFor.Comp"): WaitObj.WaitForSeconds 10

No doubt that library is just a wrapper around the sleep API call, so you could make your own if you don't want to trust some random library from some un-vetted 3d party (trusting anonymous code from un-vetted sources is not something I would not recommend, and I count as an un-vetted source). For VB6 the call would be declared as Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long).

First thing I would do at this point though, before trying either of the above, is ask over in StackOverflow to see what other people use for non-busy waits in classic ASP. You might find there is another library out there that is still supported by its creator, or a better technique altogether. As the ping trick is using CreaetObject I suspect that anything usable in a classic ASP context will be usable from your app.

share|improve this answer

Ugh! I haven't used any of the "WhatsUp" software in years, so I've lost familiarity. A quick review of their forum and a search with my friend Gooogle confirms the ugly hacks you've mentioned.

I'd go for abusing PING like we do in batch files sometimes to get a delay. It's clever, but ugly.

The alternative to being ugly would be to come up with code that doesn't need any "sleep" functionality at all. How are you monitoring MySQL? Are you connecting to it with ODBC and running a query to judge its "aliveness"?

share|improve this answer

The ping -n X 127.0.0.1 trick is a hack, but not particularly dirty. It is widely known and used in all sorts of Windows batch scripts since the last century ;)

share|improve this answer

have you tried SleepCMD

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.