Create a System Load Monitor for Mac OS X on Monitis

Apple MacA system administrator’s job is frequently an ongoing battle with complexity.  In an ideal world, we would manage all of our systems on similar or identical platforms, greatly simplifying the job of configuring, updating, and monitoring them.  In practice, the requirements of the applications we support often dictate that we manage a huge variety of operating systems and hardware platforms.

Fortunately, Monitis can help ease the pain of monitoring such disparate systems.  Previously, we’ve talked about how you can monitor almost any Linux and Windows health and performance metrics.  In this article, we’ll describe how Monitis makes it possible to leverage much of your work monitoring Linux systems to monitor your Mac OS X systems as well.

Getting started

On Windows and Linux, Monitis has an agent available with built-in monitoring.  While no such agent exists for Mac OS, this doesn’t mean that Monitis cannot be used to monitor Mac OS X.  In fact, any system that can access the web can be monitored.
For a simple example, suppose that you want to monitor the system load on an OS X system.  On the command line, you can find the load averages over the previous 1-, 5-, and 15-minute intervals with the uptime command.

$ uptime
23:08  up 5 days,  2:45, 2 users, load averages: 0.28 0.19 0.26

OS X provides a number of scripting options for taking this measurement and recording it in a Monitis custom monitor.  In future articles, we’ll discuss how to do this in python and AppleScript.  For now, let’s see how to get this into Monitis using shell scripting.

Before we can post any results, we need to create the monitor to post them to.

$ export APIKEY=<your API key>
$ export SECRETKEY=<your secret key>
$ ./

With the monitor created, the next step is to extract the load averages from the uptime command.

$ LOAD_AVGS_RESULT=`uptime | egrep -o "averages: (.*)" | while read a b c d; do echo 1m:$b\;5m:$c\;15m:$d; done`

With the results in hand, it’s then straightforward to post them to the monitor we created.  Just add the results and a few other parameters, and send an HTTP POST request to  Using curl, it would look like this.

curl --data-urlencode action=addResult --data-urlencode apikey=<API Key> --data-urlencode checktime=1309235772000 --data-urlencode monitorId=841 --data-urlencode 'results=1m:0.01;5m:0.06;15m:0.12' --data-urlencode 'timestamp=2011-06-28 04:36:12' --data-urlencode version=2 --data-urlencode checksum=bI5iQ33O2QvfcA9QiPyk0PMi/7I=

This is the same curl command used by the example script,  Let’s try it out.

$ ./ -a <API Key> -s <Secret Key>

Mac Load Average Monitor

Now we can see it in Monitis. It’s that simple.  This can be expanded to any number of different measurements.  If you haven’t already downloaded the code, now would be a great time to get it and try this yourself.

$ git clone

Cloning into Monitis-Mac-OS-scripts...
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 5 (delta 0)
Unpacking objects: 100% (5/5), done.

$ cd Monitis-Mac-OS-scripts
$ export SECRETKEY=<Secret Key>
$ export APIKEY=<API Key>
$ ./

./ -a <API Key> -s <Secret Key>

That’s it!  Monitoring with Monitis on OS X with shell scripts is quick and easy.  In future articles, we’ll look at setting up custom monitors with Python and AppleScript.


Try our free plan!

You might also like