Scripts for Simon: email on counter change; get screenshot of website

One of the major strengths of Simon, my website and server monitoring tool, is the flexibility it offers through the ability to write custom scripts in many scripting languages. Simon is plenty useful with the built-in services and notifiers, but the ability for customers to enhance it themselves makes it even better.

Recently, two notifier scripts were added. Notifier scripts enable you to provide new ways of being alerted to changes, failures or recoveries of tests.

Firstly, a useful Ruby script called "Email on Counter Change", to notify you via email when a numeric value changes. It was kindly written by a Simon customer, Wade Maxfield. He wrote it work with the output of the MySQL service, though it could be used with other services, and/or customized for different behavior. He describes it thusly:

Parses the results of the test for name/value pairs and then notifies by email if any of the values differ by more than the warningThreshold since the last check. Use a negative number as the warningThreshold if you want to check for values that decrease over time. For use with the MySQL service, and queries like SHOW global status WHERE (variable_name LIKE "Qcache%")

Requires Simon 2.4.1 or newer.

As an example: Set up a Test and Notifier to check if MySQL has restarted. For this test we will check the value of the Uptime status variable in MySQL. Since it shows the current uptime in seconds, it should not decrease, if it does send a notification email since MySQL must have restarted.

In a MySQL Service test set the Server, Port, Database and Security values to whatever are required to connect to your MySQL server, then set the Query to SHOW global status WHERE (variable_name="Uptime"). Add Notifiers for Change and Failure, and set both to use the Notifier you have setup with this script.

In the Notifier, set the mail options as needed. Set the warningThreshold to -1, then if the Uptime variable is ever lower that the previous check, MySQL must have restarted, so this script will send the notification email.

Secondly, I wrote a very simple notifier script called "Show & Screenshot" in answer to a forum query:

Opens the page in the default web browser, waits a few seconds for the page to render, then takes a screenshot of it. Enter the path of a folder to save them to (the folder must already exist). Also specify how long to wait before performing the screenshot, in seconds.

You can download these scripts and much more via the Notifier Scripts section of the Simon Extras page.

Enjoy! And if you create a useful script for Simon, please share it with others!