Dejal

This site is designed to take advantage of CSS. If you are seeing this, CSS must not be available or enabled in your browser. Everything should still work, but won't be as pretty. :)

tips

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!

Simon tip: Preview

Dejal Simon version 2.4 was recently released, and a few of the changes in this version related to the Preview window. This window may not get much love, so I thought I'd devote a tip blog post to it.

As you know, Simon is a website and server monitoring tool. This mouthful is to try to describe two of the levels that Simon operates at. At the very basic level, Simon is a very simple utility to watch web sites, and let you know when they change or go down. But Simon has much more depth to it — it enables you to monitor all sorts of internet servers and services, local applications, local and remote disk volumes, and more.

The Preview window has this duality, too. When used with a web-based test (i.e. one using the Web (HTTP) service), it displays the HTML source at the top of the window, and the rendered web page and graphics in the bottom, with a URL field, Back/Forward buttons, and more, and links etc are fully functional:

Preview for web

This is really handy, both to quickly see the page while in Simon, without having to switch to a web browser (which is easy too, via the Visit Site command), and when setting up the test in the first place.

One of Simon's key features is the Smart Change Detection function. This is a section of the Edit Test window, where you can tell Simon to only look at the HTML source between two blocks of text. This enables you to focus on the part of the page you care about, and avoid dynamic portions like banner ads etc. You can easily set this up via the Preview window. With the Edit Test window open, after entering the URL, click the Preview button to display the preview of the page. Then search through the HTML source for the start text, select it, and click the Copy to Test toolbar button. This will copy that selected text to the Start field in the Edit Test window. Then you can find and select the end text, click the button again, and it's copied to the End text field. Easy!

Smart Change Detection

As useful as this is, it's not done yet. The Preview window is also supported by many other services, in a slightly different way. For non-web services, the Preview window looks a little different. Instead of the HTML source, it displays a summary of the service operation at the top (e.g. the script), and the output at the bottom. This is all plain text, since that's what these services deal with:

Preview for others

These services support the Smart Change Detection feature, too: just like with web pages, you can select text and click Copy to Test (or copy manually) to set up the Start and End text blocks. Unlike web, you can do it from either the source or output areas (and choose those as options in the Smart Change Detection section).

The Script- and Port-based services already supported this mode, but version 2.4 extended it to include the Application and Ping services, too, along with the new Twitter service. So you can now see more information about exactly what's going on with the Ping checks, and more information about the other services. Version 2.4 also made the Preview window more responsive for this mode, showing the source script immediately, instead of after the check is complete, so you can see what it's doing.

I hope you'll use the Preview window to good advantage when configuring and using Simon.

Caboodle tip: add entry from text in another app

Caboodle is my handy snippet keeping app: as a blogger wrote recently: "Lean, clean, snippet machine to store information on your Mac."

One of the essential features of any snippet keeper is getting information into it, and Caboodle has a number of options, including direct entry, imports, and a handy Services menu command. This sub-menu is found within the application menu of modern Mac apps, and includes useful operations you can perform on selected text using external applications.

If you want to add some text to Caboodle from a web browser, word processor, text editor, or just about anywhere, you can simply select the desired text and choose Services > Caboodle > Add Entry with Selection. Caboodle will be launched, if necessary, and the selected text will be added to a new entry.

If you do this a lot, you might find it more convenient to assign a keyboard equivalent to the command. To do so, follow these simple steps to add the equivalent of your choice to the Add Entry with Selection command:

  1. Open the Keyboard & Mouse system preferences.
  2. Go to the Keyboard Shortcuts tab.
  3. Click the "+" below the list.
  4. Select Application: All Applications.
  5. Type Menu Title Add Entry with Selection (exact wording and case is important).
  6. Press Keyboard Shortcut Cmd-Option-Ctrl-C (or a shortcut of your choosing).
  7. Click Add.
  8. Launch a new application that supports Services.
  9. Select some text, press Cmd-Option-Ctrl-C, and it appears as a new entry in Caboodle.

Note: the new keyboard shortcut won't show up in applications that are already running until after you quit and re-launch them.

Use Narrator to read interviews

My German localizer, Ulf Dunkel of DSD.net, recently suggested an excellent use for Dejal Narrator. The app was designed with reading out stories using multiple voices in mind, but it's certainly not limited to that. Any text that includes multiple people is a good candidate.

One common case when people are conversing is a web interview. The format is pretty standard: each paragraph represents something one of the participants said, and is prefixed with their name or initials. Narrator's Casting Assistant feature recognizes this format, making it very easy to mark up the text.

When you find an interview you'd prefer to listen to, rather than read — perhaps just so you can rest your eyes, or maybe you want to listen to it on an iPod — you can easily use Narrator to read it out, with different voices for each of of the participants.

Here's how:

  1. Select the interview text in the web browser (e.g. this Macworld interview on iPhone gaming, or this Phorum interview).
  2. Choose Services ▶ Narrator ▶ New Document with Selection from the web browser's application menu.
  3. In Narrator, edit the names at the start of paragraphs, if necessary, to make them consistent (sometimes the first usage is a longer name).
  4. Choose Director ▶ Casting Assistant... (or click the toolbar button).
  5. Click Cast to have Narrator add Characters for the participants.
  6. Change the Actors' voice attributes, if desired.

That's it! You can then export to iTunes if desired, or listen directly in Narrator. A great way to enjoy an interview while doing other activities.

Simon on your iPhone, APC notifier, and more

One of the nice things about Dejal Simon is its flexibility. Not just in the wide range of website, server, application, etc monitoring services and notifiers, but that it can be extended by anyone, not just me.

As you may know, I have a page on the Dejal site devoted to such extensions, the Simon Extras page. Newly contributed services, notifiers, and reports tend to get bundled into the application in the next feature release, but you don't have to wait — you can download the new goodies now. In fact, existing customers need to do so to get them, as the bundled ones are only visible with the default data install for people first trying Simon (I have plans to improve that situation in the future via an enhanced update mechanism).

Here are some of the recent offerings:

  • iPhone: A report template to display reports on an iPhone or iPod touch (try it yourself with a live demo: point your iPhone at www.dejal.com/simon/iphonedemo):

    iPhone demoiPhone demo

  • APC Masterswitch: A notifier script to restart an outlet on an APC Masterswitch with Network Management Card v2.6.1. This has been requested by many others, so I'm sure will be much appreciated.
  • TCP Port Scanner: A service script to check all TCP ports on a server, to identify which are open.
  • Network Time (NTP): A service script test that an NTP server is responding.
  • Incoming Mail (POP) via SSL: A service script test that a POP3/SSL server is responding.
  • Port Available: A service script like the Port services, but simply checks if a specified port is open, without actually communicating on it.

Visit the Simon Extras page to download these and other handy goodies.

Simon tip: automatic offline support

One "hidden" feature of Simon is how it handles the situation when your computer loses its internet connection.

People sometimes ask me what Simon does in this situation, concerned that it would count as a failure for tests. Simon is smarter than that, though. Every time it starts a check, it first checks if the computer has a current internet connection, and only then performs the check.

If it determines that your internet connection has been disrupted, it places the test in an "offline" state, where it shows a blinking "lightning bolt" for the status icon until the connection is restored. This offline state doesn't count as a failure (or success).

Simon works out if you have a connection by seeing if it can resolve one of two popular domain names; if either work, your connection is probably fine, but if both fail, it is likely disconnected. Using two domains avoids a temporary outage of either one.

From version 2.3 onwards, you can disable this internet connection check on a per-test basis via the new Can check when offline checkbox in the Edit Test Checking Options. This is useful if you want to create a test to notify you when your connection goes down, or for tests that don't require an internet connection (e.g. using the Application or Script service plug-ins).

Test Options

Caboodle tip: alias a file instead of copy it

A quick tip for Caboodle, from the FAQ:

Normally when you drag a file into a Caboodle entry it copies it, allowing you to delete the original. But often you want to keep the original in place too, and want to avoid bloating Caboodle's data with large files (or folders).

The solution is to hold down the Control () key when dragging the file or folder to the Caboodle entry: the mouse pointer will change to include an alias symbol instead of the green plus. It will then make an alias (link) to the original. Then when you double-click on the file (or view it inline for images and PDFs), the original will open. Of course, in this case you shouldn't move or delete the original file.

Simon tip: shortcut for entering test URLs

The Web (HTTP) service is the most popular one for tests. So I thought I'd share a helpful tip with adding them.

When entering the URL, you can use very minimal text, and Simon will fill in the remainder when you click OK. It automatically adds the default protocol ("http://") and the "www." and ".com" if necessary.

For example, if you type "apple" (without the quotes), it will be saved as "http://www.apple.com/". Similarly, entering "dejal/simon" will end up as "http://www.dejal.com/simon/".

Web (HTTP) test

Simon tip: notify via email

I recently received a question from a potential customer, asking whether Simon has the ability to send a notification via email.

Although I do mention it in a number of places, this wasn't an unreasonable question, particularly if you just download Simon and start playing with it, as no email options appear in the list of available notifiers in the Edit Test window by default.

Why is this? Because unlike the Speech and Sound notifier plug-ins, the Email one requires some configuration before it can be used, so it can't be offered by default.

The way notifiers work is (I hope) pretty intuitive, but a little indirect. Simon provides a number of notifier plug-ins that do the work of notifications, and you configure notifiers to use those plug-ins, then choose notifiers for each test.

These levels of abstraction allow easy re-use of notifiers: a single plug-in can be used by multiple notifiers, and a single notifier can be used by multiple tests, without having to set up the same things over and over again.

For example, you can add an email notifier to yourself for some failures, another email notifier to your clients for other failures, another one for recoveries, and so on, and use whichever ones of those are desired in tens or hundreds of tests, as required, as simply as choosing them from a pop-up menu.

Test Notifiers

So, as I said, there is no email notifier set up by default, since it needs configuration, but you can easily add one. If you're editing a test and realize that you want to receive an email or SMS when this test changes, fails, and/or recovers, you can click the New Notifier... button in the Notifiers section of the Edit Test window, which will open the New Notifier window. You can then choose E-mail from the Notifier Kind pop-up menu, and the controls below will change to those for the email plug-in:

Email Notifier plug-in

You can then configure the email, and save the notifier, which will be available for that test and any others you want to use it in. Easy!

Simon tip: detect unacceptable changes

Simon's Smart Change Detection feature looks for the text in the Start text box, then the End text, then compares the text between those two against what it had the last time it checked.

This is useful to detect changes in a portion of the page, but can also be used to detect unacceptable changes.

The usual way to do that is to just provide a Start text block, and not an End one. Then if the Start text isn't found, that is a failure.

So for example, if you do a telnet Script-based check, you'd want it to be considered a success only if this is output:

Escape character is '^]'

So you'd put that in the Start text block, and leave the End block empty.

Then if that text isn't found (as would occur if telnet couldn't connect to the server), Simon will log a failure.

Syndicate content