Getting startedAugust 06. 2010
PreparationsNagios needs to be runningSince Check_MK is an Addon for Nagios, you first need a fully functional running installation of Nagios before you can start with Check_MK. You need at least version 3.0 of Nagios. Check_MK is known to work with 3.0.X, 3.1.X and 3.2.X. It does not matter wether you use a prepacked version from your Linux distro or have compiled Nagios yourself. Please also make sure that your Nagios is configured correctly for external commands. You need to be able to control Nagios via its WWW interface. If you are unsure, then you can check by selecting an arbitrary service and try if Disable active checks is working. If not - please refer to your Nagios documentation about how to enable external commands for the WWW interface. PythonCheck_MK needs Python in version 2.X (at least 2.3). Most Linux distributions include Python in their default (or even minimal) installation. If unsure, call python --version from your command line. Check_MK is not compatible with Python 3. XinetdCheck_MK needs xinetd for running the agent on the local host. Some but not all distributions include xinetd in their default installation. A package called xinetd is available in all major distributions. If xinetd is not available you can use the classical inetd as well but you have to configure it yourself. Check_MK prefes xinetd, because it supports IP address based access control out of the box and also is easier to configure. Installation of Check_MKAfter you've made your preparations and your Nagios is up and running you are ready to start. Download the installation tarball of Check_MK from its project homepage. Its name is check_mk-VERSION.tar.gz, for example check_mk-1.1.6p1.tar.gz. Unpack it at a convenient place. Unpacking Check_MK does not need root priviledges and can be done as normal user. but the installation itself needs to be run as root (well, it also possible to install Check_MK as a non-root user, but that is out of the scope of this tutorial). The following example assumes that you work as root and unpack the installation tarball below /root: root@linux# cd /root root@linux# tar xzf check_mk-1.1.6p1.tar.gz root@linux# cd check_mk-1.1.6p1 Now run the script ./setup.sh (do not run install_nagios.sh): root@linux# ./setup.sh
Installation pathsThe setup script will now ask you for installations paths and other settings. Hitting enter keeps the default or detected value of a setting. Entering another value will override the proposed value. Please always use absolute paths (beginning with a slash). The first settings deal with the installation paths of Check_MK itself. Check_MK tries to be compliant with the Filesystem Hierarchy Standard (which is part of the Linux Standards Base). You are free to choose alternative paths, but please keep in mind, that all examples in the documentation of Check_MK refer to the default installations paths. Integration with NagiosThe further settings deal with the integration with Nagios und PNP4Nagios. In most cases there is only one correct possible answer. The setup script will examine your running Nagios installation and try to autodetect all those settings. If no Nagios is found running, the autodetection will fail and you will have to configure all settings manually. While this is possible, it requires profound Nagios experiance. InstallationAfter all setting are done, you have a last chance to confirm or abort the installation. If you confirm, then all your settings will be saved to /root/.check_mk_setup.conf. The next time you call setup.sh - all your previous settings will be read and restored. This is very usfull when updating Check_MK to a new version. If you want to repeat the installation with other settings then simply delete ~/.check_mk_setup.conf before calling setup.sh. After the setup has finished you should be able to call check_mk:
user@host> check_mk --version
check_mk --version
This is check_mk version 1.1.6p1
Copyright (C) 2009 Mathias Kettner
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
Installing the Linux agentThe easiest way for getting started is to monitor the Nagios server itself as a first host. It is not different from monitoring any other host and thus illustrates how to add a host to your monitoring. Before you can monitor a host with Check_MK, you need to install an agent on that host. SNMP Monitoring is also possible and uses the existing SNMP agent, but is not covered by this tutorial. Installation of the agentIf your Linux distribution is based on RPM (RedHat, FEDORA, CentOS, SUSE, Mandriva), or on DEB (Debian, Ubuntu), you'll find a prepackaged agent on the project homepage. The installation is done with one single command: root@linux# rpm -i check_mk-agent-1.1.6p1-1.noarch.rpm or - for Debian: root@linux# dpkg -i check-mk-agent_1.1.6p1-2_all.deb Please remember that you need the package xinetd from your distribution to be installed as well. It is also possible to install the agent manually. Please refer to the Installation procedure for the Linux agent in that case. Configuring Check_MKNow that the agent on localhost is installed and ready, you can enter localhost as your first host to be monitored into the configuration of Check_MK. Check_MK is configured via the file main.mk, which resides in /etc/check_mk (as long as you haven't changed that path during setup.sh). Many nifty things can be configured in main.mk, but currently we need only one variable: all_hosts. That variable lists all hosts (hostnames) that you want to monitor with Check_MK. For a start we begin with localhost: /etc/check_mk/main.mk all_hosts = [ "localhost" ] More hosts can be listed in all_hosts if you separate them with commas. It is allowed to use newlines as long as the opening bracket is in the same line as the variable all_hosts: /etc/check_mk/main.mk all_hosts = [ "localhost", "host1", "host2", "host3", "host4", "host5", "host6" ] After having added localhost to all_hosts you can do your first Inventory. During intentory Check_MK retrieves all data from the hosts listed in all_hosts and scans it for items that should be monitored. This is done by calling check_mk with the arguments -I tcp: root@linux# check_mk -I tcp cpu.loads 1 new checks cpu.threads 1 new checks df 1 new checks diskstat 2 new checks kernel 3 new checks kernel.util 1 new checks local 2 new checks mem.used 1 new checks mem.vmalloc 1 new checks mrpe 2 new checks netctr.combined 2 new checks ps 1 new checks In our example eleven items have been found. They will result in eleven separate Nagios services. If you run the inventory for a second time, only new items will be found. If you haven't added a host to all_hosts and also none of your host has a new item since your last inventory (for example a new filesystem or network interface), then nothing will be found. If your first inventory does not find any item, please make sure that your agent is properly working. Please refer to the article on setting up the linux agent for details. Integration into NagiosCheck_MK now has done most of its work. But we still need to get our eleven new checks into Nagios. Check_MK does this for you by creating a Nagios configuration file check_mk_objects.cfg that contains definitions for all hosts and services handled by Check_MK. At setup you have defined a directory where that file will be put. It is vital that Nagios reads in that file on each restart. If your autodetection worked, then this will be the case, as setup.sh takes care that your Nagios is configured properly. Also a second file check_mk_templates.cfg needs to be read in. This is a static file and installed during setup into the same directory. Check_MK provides several command line options for generating the Nagios configuration. The most comfortable way is to use check_mk -O. That does not only create or update your Nagios configuration but also reloads Nagios when everything is ready, thus making the new configuration active. Furthermore it also makes sure that the configuration is valid and leaves the Nagios configuration unchanged if that is not the case. That way you won't be left without a running Nagios if any problem occurs. Speaking of problems - one thing must still be taken care of: Your Nagios installation might already have a definition of localhost. If this is the case you will get a duplicate host entry and Nagios will not start. You can solve this problem in two ways:
If every goes fine, this should look like this: root@linux# check_mk -O Generating Nagios configuration...OK Validating Nagios configuration...OK Precompiling host checks...OK Reloading Nagios...OK Now you show see the new checks in your Nagios GUI. After the active check Check_MK has run, the services of localhost should look similar to this:
|
| |||||||||||||||||||||