Just the other day, my router died because of a slight power outtage. I'm not too bent out of shape over it, because it was on the fritz anyways, but it got me thinking, I should have better power management setup in my house. I dropped by Circuit City and got me a relatively cheap UPS from APC. Boy was I impressed when I plugged the USB connection into my server.
It just showed up as a battery for my system! Just like my laptop!
So while that was cool, I noticed I could run apps as things died. Wouldn't it be great to get notified of a power outage? and have the server shut itself down?. Well, you have this handy tool called Microsoft Exchange Server on the server, which just so happens to excel at sending mail!
So, I decided I wanted to have the server send me mail when it dropped onto battery power, and again, just before it shut down, so I toyed with the alert bars, and built some VBScripts to get just that working!
As you can see, I wrote two different scripts (they were both small, and it beats trying to figure out what alert level we're at!) for each alert level. I was struggling to write the scripts, so my man Adam came through with some help. Here is what my script looks like {email address changed to de-spam the innocent}. I just have a file called PowerOut.vbs, with the following content:
Dim MyMail
Set MyMail = CreateObject("CDO.Message")
MyMail.From = "administrator@fqdn.com"
MyMail.To = "externaluser@fqdn2.com;phone#@smsaddy.com"
MyMail.Subject = "Power Outtage for YOUR DOMAIN"
MyMail.TextBody = "Power Outtage for YOUR DOMAIN"
MyMail.Fields("urn:schemas:mailheader:X-MSMail-Priority") = 0
MyMail.Send
Set MyMail = Nothing
Then, I just configure the program to run as the .vbs script. Note that it's expecting a .exe or .com file, so you'll have to change it to all files to be able to see the .vbs file when your choosing which program to run.
You'll also notice that I put in my SMS address, which works well in North America because SMS addresses are emailable directly from the Internet, some countries/providers do not offer this service. :(
Also, keep in mind that I'm not a Microsoft dev, and I've tested this on my own home server, that's it, so use at your own risk!
4 comments:
Well, I assume that if you want your mail to be sent, you have connected your swith and modem (or any other networking equipment) to your UPS as well. I wonder which kind of power cables you used (because my own APC UPS comes with thick power cables that are OK for connecting computers but not for switch AC adapters).
Then you need to get yourself some of these: Power Extenders
I had a battery failure on my UPS and just got the new one. It came with APC business edition basic. It has to be better than powerchute plus, right? Wrong, it disables native UPS capability in the OS and doesn't allow you to run a script unless you upgrade to their full business edition. I guess I'll install the 6 year old copy of powerchute plus if I can find the CD
Very strange, and if you un-install it can you not run the native OS utilities? I'm surprised that a new APC UPS doesn't just plug into the OS as mine did. Very strange indeed, have you tried contacting APC support to see what they say about it?
Post a Comment