May 2012

2012-05-03

Powershell and database monitoring

I like Powershell, a lot; it makes Windows worth using (for me anyway).

For a variety of reasons my current work environment uses Oracle, DB2 and SQL Server and, given the correct client software is installed, Powershell can connect to all of them.

Having developed a suite of database access modules it is now very easy to implement a Powershell monitor that will connect to a database (of any flavour), run a query and either save or report on the results.

Now I don't know about you but I detest receiving warning and alert emails, most of the time they serve no useful purpose.
Take the supplier of our managed service; they insist on sending emails when a server goes over 95% CPU or memory usage and that happens often; pointless.

Our monitoring scripts use Powershell to update RSS feeds which we monitor from our workstations using whatever feed reader we happen to prefer.
This has a number of advantages:

  1. Our inboxes don't get clogged up with emails.
  2. The feeds include a 'success, no errors' feed so we can easily see when a monitoring job fails.
  3. Each failure includes a link to a report with as much detail as the script was able to gather.
  4. Feed reader software automatically maintains the number of messages retained.

If I can get authorisation from my employer I'll make the Powershell database access and RSS modules available.