Revisiting Nagios to monitor IBM i

It’s been a while since I played with Nagios but my son had recently shown me the Cacti plugin that works with Nagios and it was cool enough that I decided to get Nagios up and running again.

I have an SLES 11 SP1 PPC64 Linux installation that is running on my JS12 blade under VIOS (that is a mouthful!) and although I intend to run Asterisk on the JS12, I have plenty of running room for Nagios as well so I went ahead and installed Nagios. The Quickstart guide was the easiest for me.  It recommended using wget to pull the files and everything went smoothly from there. The biggest requirements are to make sure you have php and java installed but most servers these days would have those common applications already installed.

Right after I got it installed I realized I had a hosed up PHP5 installation that I had never really addressed.  I also had a devil of a time getting the KDE desktop running, all of which came back to haunt me.  I traced the PHP5 problem to a mod_php5.so module that wasn’t flagged as executable and finally got the basic Nagios web app running under Apache. The desktop is still a little squirrely but it works well enough to move around.

The next thing to do was to install the client apps for the IBM i.  I remember being *very* confused about how to get all of this working on the i before.  The confusion comes from where to install the files Nagios needs in order to run the scripts for the i.  Long ago I thought they went on the i (NO!  Nothing is installed on the i) and the instructions from the ancient version of the as400NagioPlugin were a little lean and unclear as well.  You can find the as400NagiosPlugin at the sourceforge.net site.

The simple instruction is that everything hangs out in the nagios folder in Linux, which in my case is /usr/local/nagios.  On the  Linux box where Nagios is installed, untar the file to a convenient place and then run the ./install script.  It will prompt you for your Nagios installation folder and also for your Java executable location. You will need to do a quick hack of the .as400 file in the libexec folder of nagios to change the userid and password to log on to the IBM i (remember that the “.” makes it hidden).  In the current version of as400NagiosPlugin the checkcommands.cfg file is supposed to go in the /etc folder.  What I did is rename the file to ibmicommands.cfg and dropped it into the /usr/local/nagios/etc/objects folder.  I also hacked the templates.cfg file to add a ibmi-server type just in case you want to have some server specific settings just for your i. I also added an ibmi-server (copy of the local-service service) just in case you want to tweak your IBM i settings.

The actual services that will run and check in with the i are in services.example which I changed to ibmi.cfg and put in the /usr/local/nagios/etc/objects folder.

I don’t know if this is a recent Nagios change or not but the final step in all this is to change the nagios.cfg to add the ibmicommands.cfg  and ibmi.cfg file references to the files referenced in nagios.cfg. I placed the ibmicommands.cfg reference just after the commands.cfg line e.g.

cfg_file=/usr/local/nagios/etc/objects/commands.cfg

cfg_file=/usr/local/nagios/etc/objects/ibmicommands.cfg

I added the ibmi.cfg reference in the section just after the entry for Linux servers:

# Definitions for monitoring an IBM i machine

cfg_file=/usr/local/nagios/etc/objects/ibmi.cfg

I have zipped up the relevant files as examples.  Remember that nagios.cfg goes in the etc folder in the nagios folder and the ibmicommands.cfg, ibmi.cfg and templates.cfg files go in the etc/objects folder in the nagios folder. Make sure you change the IP of the IBMihost in the ibmi.cfg.  Also, and this is very important, telnet uses unencrypted text to communicate to the server so the user ID and password are being sent unencrypted.  I hope to fix this by adding the tn5250j jar to the mix and using the 5250 protocol bean to communicate with the i  using SSL.

You can find the configuration files I used (hacked)  here.

The next “to-do’s” on the list are to add some more Java methods that implement service checking on the i.  I’d like to monitor the web servers I run and things like JDBC connections, etc.  I also want to get Cacti installed and running. I also want to add the SSL option using tn5250j.  Of course I’ll post back here as I make more progress.

It has been nice to revisit Nagios now that I clearly understand how the client agents work with the servers that they monitor.  Still some more work to do to make this a bit more secure and robust, but this was quick, easy and adds the IBM i to the servers I can monitor with Nagios.

This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.