views:

318

answers:

5

I've got a service that acts as a watchdog for several apps/servers. There are no user sessions on this machine. I'd like the watchdog to be capable of beeping on the internal speaker should something go wrong (that'd be my queue to go fix whatever it's complaining about)

when I try the Beep() API on Windows nothing happens - I suspect the problem is that the services session isnt permitted to make noises?

can I make this work? any other ideas for how to make the service alert me?

-CG

+1  A: 

It may work if you allow it to interact with the desktop (an option configurable somewhere, I can't remember where).

But personally, I'd have it email me.

Though maybe you could have it use the task scheduling API to schedule a task for yourself, so next time you log on you can see it.

I don't know; you've got a few options. I'd avoid beeping though.

Noon Silk
A: 

Try sending beep char "\a" to console. Not sure if it will work.

aloneguid
+2  A: 

Call CreateFile on \device\beep, then send down IOCTL_BEEP_SET (see http://www.koders.com/c/fidFEC3527B9D951559D62722A9C0C603863106CA9B.aspx for details)

Paul Betts
A: 

Beeping doesn't seem like a good idea - it might end up driving everyone mad.... I'd also agree about the "interact with desktop" option and you set this in the services parameters see A Windows Service without a template

mikej
A: 

I'd recommend creating a simple client application that polls that server to query for any problems and returns a set of status messages. Then an appropriate UI would be raised (e.g. balloon on the tray), an email sent, etc. containing any warning or failure messages.

This way you also know that the watchdog itself is running and has network connectivity - if the watchdog dies and/or machine locks up you wouldn't otherwise know.

It also avoids being thrown out of a window when the machine starts beeping continuously just after you go to lunch. [+1 to @mikej] :-)

The poll period should be around half (see Nyquist sampling rate) your minimum required response time.

devstuff