AussieBroadband CheckMK Plugin

I’ve recently changed my ISP to AussieBroadband.  Since I’m now working under a quota, I want a way to monitor my quota in CheckMK.  Enter a bit of python.  If you want to use this, you’ll need to adjust the hashbang to suit your actual OMD site, and then pass a parameter which is your username:password to get onto your ABB account.

# Parses AussieBroadband Quota Page to generate a CheckMK alert and stats pages

import requests
import re
import time
import sys
import json

status = 0
statustext = "OK"

creds = sys.argv[1].split(":")

# Create a new session
s = requests.Session()

# Process a logon
headers = {
'User-Agent': ''
payload = {
'username': creds[0],
'password': creds[1]
}'', headers=headers, data=payload)

# Fetch customer data and service id
r = s.get('', headers=headers)
customer = json.loads(r.text)
sid = str(customer["services"]["NBN"][0]["service_id"])

# Fetch usage of the first service id
r = s.get(''+sid+'/usage', headers=headers)
usage = json.loads(r.text)
quota_left = usage["remainingMb"]
quota_up = usage["uploadedMb"]
quota_down = usage["downloadedMb"]

# Derive some parameters for the check
total = quota_left + quota_up + quota_down
critthresh = 0.10*total
warnthresh = 0.25*total

# Determine the status of the check
if quota_left < critthresh:
status = 2
statustext = "CRITICAL"
elif quota_left < warnthresh:
status = 1
statustext = "WARNING"

# Format the output message
print "{7} - {1} MB quota remaining|left={1};{2};{3};0;{4}, upload={5}, download={6}".format( \
status, \
int(quota_left), \
int(warnthresh), \
int(critthresh), \
int(total), \
int(quota_up), \
int(quota_down), \

print "UNKNOWN - Unable to parse usage page!"
status = 3
statustext = "UNKNOWN"


Enjoy.  It’s pretty quick and dirty, but it works.  You put this into your site’s local/lib/nagios/plugins directory, then add it as a classical check.

Raspberry Pi Temperature Monitoring with CheckMK

The Raspberry Pi running Raspian has some built-in temperature sensors.  The sensor is on the CPU die, and you can find it at;


CheckMK supports the idea of local checks.  A local check is a simple script that runs in the agent on a host and performs whatever check processing and verification that’s required on the client end.  This means you cannot customize the warn/crit thresholds from the CheckMK host end.  But they’re easy to write.

The above simplistic script reads in the CPU temperature of the RPi, and sets a warn threshold of 90% of the throttling temperature with a critical threshold of 100% of the throttling temperature.

If you add this into;


On your Raspian install, then manually run check_mk_agent, you’ll see in the <<<local>>> section the output from the sensor.  You can then edit the host in CheckMK and add the new service that is automatically inventoried.  I assume here that your CPU die never gets below 0 degrees (should be fairly sensible in most circumstances, I imagine).


HWiNFO Sensors in CheckMK

I use HWiNFO64 on my Windows PCs to monitor the various temperature and fan sensors.  I wanted to get this data into CheckMK for monitoring purposes.  Here’s how I did it.

First, in HWiNFO, tag any sensors you want to monitor for the Vista gadget.  This causes HWiNFO to populate registry keys with the relevant data.  You’ll then need to make a custom plugin for CheckMK in C:\Program Files (x86)\checkmk\plugins named “hwinfo64.cmd”, containing the following;

Now, do a test on your CheckMK server, you should see the <<<hwinfo64>>> fields in your agent output for the host.  Great.  Now we need to write a check in CheckMK to interpret that data.  Make a new check ‘hwinfo64’ in /omd/sites/SITENAME/local/share/check_mk/checks, replacing SITENAME with your OMD site name;

Apologies for the terrible Python, my Python is very weak.  Also note that this assumes that all temperature-type sensors are in Celsius units, and all fan-type sensors are in RPM units.

Once that’s done, you should be able to add services to your host and the HWiNFO sensors will be automatically inventoried and show up.  They will use some default thresholds.  In order to customize those thresholds, edit etc/check_mk/ in your OMD site and do something like this;

That will set the warning/crit threshold for CPU temp checks at 70/80 C, and the threshold for GPU checks at 90/100 C, on the machines ‘desktop1’ and ‘desktop2’.  Set as appropriate for your environment.

Legacy Nagios checks with CheckMK

I’ve recently started converting my old Nagios installs across to using CheckMK.  As part of this, I have a collection of old Nagios checks that I want to be able to use verbatim in CheckMK as legacy checks.  Here’s how you do that.

After you create your site using OMD, go into the site with ‘su – <sitename>’.  Then, edit etc/check_mk/ and add something like this;

legacy_checks = [
  ( ( "check_solar!250!100", "Solar Output", True), [ "inverter" ] ),

extra_nagios_conf += r"""
  # 'check_solar' - Checks status of solar array
  # ARG1 = Warning level
  # ARG2 = Critical level
  define command{
    command_name check_solar
    command_line $USER2$/check_solar $ARG1$ $ARG2$

Now, put your script (in this case it’s check_solar) into local/lib/nagios/plugins/ .  What’s going on here is this;

  • Define a legacy Nagios check calling the command check_solar with parameters 250 and 100.  The check will have a description of Solar Output, outputs performance statistics, and will be assigned to the host named inverter.
  • Define a chunk of legacy Nagios config defining the check_solar command.

Then, go into your inverter host, edit services, and the manual service should appear.  Save config and you’re done!  Pretty easy.