Check_MK Custom Host Icon with Link to Mediawiki Page

This guide can obviously be adjusted to suit your setup, though is a guide to create a custom ‘Website’ Icon on each of your Check_MK hosts to link to a Mediawiki page.

I currently have my mediawiki server with a separate page created for each server that I manage, this has worked out well as I can use the Nagios Mediawiki Plugin to show the server status on it’s Mediawiki page – Though I have also now reversed this so I can browse to the Mediawiki Intranet page for each server directly from Check_MK.

You will need to adjust the below depending on both your Check_MK and Mediawiki installations (Also you can simply adjust the paths etc to send the link wherever you would like for it to go).

The first thing to do will be to create the icon file which will be loaded by Check_MK. I have set this icon to appear next to the “Check_MK” service for each host as I can guarantee all of my hosts have this Service included.

nano /usr/share/check_mk/web/plugins/icons/intranet.py

#!/usr/bin/python
# encoding: utf-8

def paint_http_icon(what, row, tags, custom_vars):
    if what == ‘service’ and row[‘service_description’].startswith(‘Check_MK’):
        url = ‘[your-mediawiki-install]/%s’ % row[‘host_name’]
        return u'<a href=”%s” target=”blank” title=”Intranet Page”>’ \
               ‘<img class=”icon” src=”images/icon_www.png”/></a>’ % (url)

multisite_icons.append({
    ‘paint’: paint_http_icon,
    ‘host_columns’: [ ‘address’ ],
    ‘service_columns’: [ ‘host_address’ ],
})

The above will apply the link to each service starting with “Check_MK” and create a new icon to my Mediawiki install server/(The hostname of the machine).

Eg one host is called ubuntu-web – The intranet page for this server is http://intranet.timharrison.me.uk/index.php/ubuntu-web.

The url line for my install reads as follows: url = ‘http://intranet.timharrison.me.uk/index.php/%s’ % row[‘host_name’]

Once you have created and saved the above file, restart apache on your server and this should now show up for each “Check_MK” service across each of your hosts.

Check_MK intranet

Any comments or questions? Get in touch here or Email me at [email protected]