« Raspberry Pi | Main | Tsunami »

Monday, April 29, 2013

Migrating Nagios Configuration from Nagmin to Check_MK's WATO

When I first set up a Nagios server, many years ago, in the days of Nagios 1.x, the best configuration tool I could find was Fred Reimers' Nagmin. That has since turned into abandonware, but there is a fork, NagminV, under development.

I'd patched Nagmin to support Nagios 2.x and 3.x, and added a few fields to its database, but it was still buggy and quirky.

So, after I'd installed Mathias Kettner's Check_MK for its livestatus broker module for use with PNP4Nagios, I started investigating Check_MK's broader features.

What soon caught my eye was Check_MK's use of rulesets based on host tags. The temptation of editing text files (python scripts in disguise) was too great for me, so I started converting my Nagios service checks into Check_MK format.

These are very rough notes, proceed with caution. Back up everything first!!!

First thing to do was get Check_MK's agent on all our hosts.

Then, to list all of them in /etc/check_mk/main.mk:

# don't generate host config yet
# comment this out when Nagmin is decommissioned
generate_hostconf = False
all_hosts = [

Then I added the obvious tags, win, linux, etc, and created config files for legacy checks in /etc/check_mk/conf.d, until eventually all service checks were defined in Check_MK and not in Nagmin.

After each check was migrated to Check_MK, I'd run

check_mk -U
nagios -v /etc/nagios/nagios.cfg

The first command generates a new Nagios config in /etc/nagios/check_mk.d/check_mk_objects.cfg

The second validates the resulting config. Here I'd find duplicate definitions, reminding me to delete them from Nagmin.

So, after a while plodding away at this - in my case this meant over a year of coexistence - all that was left in Nagmin was hosts, host groups, contacts, contact groups, and timeperiods.

Time to abandon Nagmin and get serious.

Do not, under any circumstances, try to generate a Nagios config using Nagmin again. It will always fail!

Comment out the Command.cfg include in nagios.cfg


Try validating the nagios config again, with nagios -v. If it fails, you've forgotten to define some commands as legacy checks

Rinse, repeat until you've got it right.

Check the contents of /etc/nagios/Services.cfg - if it contains any service definitions, you've forgotten something.

Do the same with all the service-related .cfg files; if things fail, change your config to use Check_MK's default service templates.

Get your custom Time Periods into WATO - check_mk has a default, hidden timeperiod 24X7 (Nagmin's is 24x7, case matters), and comment out TimePeriods.cfg in nagios.cfg. Revalidate.

And so on till you're left only with hosts, host groups, contacts, and contact groups from the original Nagmin.

So now was the time to take the leap and use Check_MK's WATO to configure nagios.

I created contacts and contact groups manually in WATO. There's no conflict with your existing Nagios config until you associate a contact group with hosts and/or services in WATO. That was the last thing I did.

Now comes the fun bit.

We need to import our hosts into WATO.

Run the attached hosts.py which will generate a list of hosts in the format hostname;alias;parents;ipaddress

python hosts.py >wato.csv

Our import script requires a file containing

wato folder;hostname;alias;parents;ipaddress;tags

where tags is a list of check_mk tags separated by |

So, we'll have to manually edit it. I didn't use WATO folders so just preceded each line with a ;

Tags are the fun bits. By now you may have been using them in your check_mk config. WATO comes with some predefined ones, which we need to list in our import file (wato.csv).

You'll need one each of the 'agent', 'criticality', and 'networking' tags. As well as your custom tags, which should also be entered into WATO.

Download and edit my_wato_import.py adding your tag definitions into tagz, run:

python my_wato_import.py wato.csv

and watch the output scroll by. If there are any errors reported, then you've forgotten to add a tag definition to tagz, or misspelt a tag in wato.csv. Rinse and repeat until all's well.

Set testing = False near the top of the script, and run again.

Comment out generate_hostconf = False in your main.mk, and check_mk -U

Comment out Host.cfg in /etc/nagios/nagios.cfg

Validate your nagios configuration. It should be OK.

A look in WATO will show all your hosts, with appropriate tags.

Hidden away in /usr/share/doc/check_mk/treasures is a script wato_host_svc_groups.py

I ran this against my original Nagmin Hosts.cfg file, which produced output which was easily massaged into the form needed for WATO. I could have amended the script to produce output of the following form, but a few regular-expression search and replaces got me there quickly enough.

host_groups = [
( 'group1', []. ['server1', 'server2']),
( 'group2', []. ['server3', 'server3']),

Place that code into /etc/check_mk/conf.d/wato/rules.mk and create the host groups (with descriptions) in WATO. Before applying changes in WATO, run check_mk -U

Comment out the Hostgroup.cfg include in nagios.cfg, and validate config once more.


Now, if you've done everything properly, the Nagios config validation will succeed, and on a restart of Nagios your host groups will be there as before.

That just leaves Contacts, Contact Groups and notifications.

I'll leave that as an exercise for the reader. Hint: don't try any of the above until you've figured out how to apply contact groups to hosts and services.

And you'll also need to adjust host and service check intervals and retries in WATO too, otherwise everything gets polled every minute, which probably isn't what you want.

Posted by Phil at 9:59 PM
Edited on: Wednesday, April 01, 2015 9:24 PM
Categories: IT, Software

Thursday, September 02, 2010

Installing Exchange 2010 Service Pack 1

I had a few hassles installing Microsoft Exchange 2010 SP1 today.

I guess if things ran smoothly all the time, I wouldn't have a job, but....

All worked perfectly yesterday on our virtualised test setup, but in real life, it is never that simple.

The Exchange Team have provided a handy list of prerequisites and known problems with SP1 in their "Exchange 2010 SP1 FAQ and Known Issues" blog post. Read it carefully.

On one of our CAS servers, I got an error warning me of a failed installation. Following the instructions in "How does Exchange 2007 setup know to resume a failed setup?", I determined that there had been a previous error installing the Admin Tools. Clobbering the registry entry (the one with the install value) enabled the install to proceed.

After the install, an attempt to start the Management Console failed. Turning again to the MS Exchange Team's blog provided the solution, in "Troubleshooting Exchange 2010 Management Tools startup issues". In our case, the Service Pack install had stripped the WSMan module entry from the global modules section of C:\Windows\System32\Inetsrv\config\ApplicationHost.config. Adding it back in after the SP1 install and restarting the default web site, that issue was solved. We had to do this on all our Exchange 2010 boxes.

Next error came moving the active database from one DAG member server to another. Corrupt index. After a quick Google I discovered that restarting the Windows Search (Exchange) service on the Mailbox servers was enough to fix this issue. I guess a reboot after the Service Pack install would have had the same effect, even though the Service Pack install didn't request one.

It is all working fine now (fingers crossed).

Posted by Phil at 9:07 PM
Edited on: Thursday, September 02, 2010 9:50 PM
Categories: Comment, Software

Friday, August 11, 2006

Active Virus Shield

AOL is widely regarded as an evil empire, second only to Microsoft, but this week they redeemed themselves somewhat by releasing a free Windows antivirus program, Active Virus Shield, based on Kapersky Labs' Personal Antivirus.

I've given it a whirl here and so far I'm impressed. Kapersky's Virus scanning engine is one of the best, and they are renowned for the speed of their responses to new malware. So far I'm seeing several pattern updates a day, which is what I'd expect from any proper antivirus vendor.

It's staying on my PC for a while. It may yet replace Alwil's Avast! here, but I have a certain irrational fondness for products whose support forums give the users direct contact with the developers.

Postscript, September 5th

Independent research confirms Active Virus Shield as being one of the best antivirus products. There's commentary and discussion over at cybernetnews.com.

Posted by Phil at 11:00 PM
Edited on: Tuesday, September 05, 2006 11:56 AM
Categories: Computer Security, Software

Thursday, June 08, 2006

Mentioned in Dispatches

Thanks Blake, for your kind mention in your weblog. I'm honoured!

Posted by Phil at 9:50 PM
Edited on: Thursday, June 08, 2006 9:52 PM
Categories: Software, Waffle

Saturday, April 30, 2005


Congratulations to the Mozilla Firefox team on their 50 millionth download.

50 million downloads counted

I was a bit slow with the screenshot there :-)

Posted by Phil at 12:20 PM
Edited on: Wednesday, April 01, 2015 9:59 PM
Categories: Software

Monday, September 20, 2004

I'm a Firefoxer

My humblest apologies to Prodigy...

If you're bored you might want to check out my other blog at SpreadFirefox.

Posted by Phil at 9:36 PM
Edited on: Saturday, April 23, 2005 10:20 AM
Categories: Software

Tuesday, January 14, 2003

Favourite Software

Just because you asked (or didn't), here's my favourite software, in no particular order:

Mozilla, the most standards-compliant web browser out there.

Audacity, for sound file editing.

Gnucleus, a peer-to-peer filesharing client completely free of spyware.

The GIMP, the graphics program which doesn't cost an arm and a leg. Installing it on windows is a bit involved, however.

OpenOffice, who needs Microsoft's bloatware when this will do nicely for most people?

All the above are open source and free to use wherever you like.

ConText, a lean and mean text editor. Free, no source included.

IrfanView, a great image viewer. Free for personal use, no source included.

Spybot Search and Destroy, the best SpyWare/AdWare cleaner.

So tell me, who needs to pay for software?

Posted by Phil at 9:03 PM
Edited on: Saturday, April 23, 2005 10:22 AM
Categories: Software