A few weeks ago I blogged about using PowerGadgets to create custom dashboards to monitor Virtual Infrastructure performance. It was a great example of how easy it is to combine different domains within PowerShell.
Today I want to talk about a slightly different type of monitoring: alarms. VirtualCenter provides a very sophisticated alarm generation system. The problem is, what if you’re not in VirtualCenter watching the alarm tab? Wouldn’t it be better if alarms would reach out and find you wherever you are?
Again, PowerShell provides a very easy solution, due to the ease in which it combines different domains. The VI Toolkit (for Windows) makes it easy to get alarms from VirtualCenter, and /n software’s NetCmdlets makes it really easy to send instant messages. Combine the two and you have a monitoring solution that just about anyone can write and customize.
First, a bit of background: NetCmdlets provides a lot of really useful functionality to PowerShell, including sending email, logging into servers via SSH, downloading files via FTP and a lot more. As usual, the cmdlets come with a very easy syntax, built in documentation and are very easy to learn and use.
Taking that, and combining it with the VI Toolkit (for Windows), I wrote a script that monitors VirtualCenter for alarms and, when it sees new alarms, sends an IM using NetCmdlets. (Note that when you run the script, you are prompted for a login. This login is the login to your Jabber server, not to VirtualCenter.) NetCmdlets currently only supports Jabber as an IM protocol, but more protocols may be added in the future. If IM is not your thing, it’s also really easy to get NetCmdlets to send email instead.
Here’s an example of the results:
The best thing about this is it only took me a couple of hours to put together, and that was mostly due to alarms not being easy enough to access from the current version of the Toolkit (we’ll fix this in a later release, but the script above also contains a script cmdlet that returns all alarms.) Developing a solution like this using other technologies would have taken substantially longer, and wouldn’t have been as easy to customize when they were complete. This, to me, is the real power of PowerShell.
So, if you haven’t tried the VI Toolkit (for Windows) there’s no reason you shouldn’t download it today.