Nagios3 is an excellent monitoring engine, but the stock Nagios has some limitations in regard to dual-stack hosts. In the Nagios universe, one host is one ip address, and a secondary ipv6 address would require an extra host definition.
The Nagios packages which you are about to install have been patched to support this concept "one host = 1 ipv4 address + 1 optional ipv6 address". The mknagconf script makes it easier to maintain your Nagios installation. mknagconf takes small short, and simple definition files, parses them and generate the configuration files for Nagios. This will be explained after installing the required software.
Step 1: Install all dependencies
apt-get install apache2-mpm-prefork apache2-utils apache2.2-bin \ apache2.2-common bsd-mailx libapache2-mod-php5 libapr1 \ libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap \ libgd2-noxpm libjpeg62 libperl5.10 nagios-plugins-basic \ php5-common postfix ssl-cert nagios-plugins-standard \ nagios-plugins-extra git-core makeStep 2: obtain PGP key, configure apt to fetch updates from my repo
Add my PGP key to your apt setup and install the Nagios packages from my repository:
apt-key adv --keyserver keyserver.stack.nl --recv-keys 7E5BEC10 echo "deb http://snijders-it.nl/deb natty main" \ > /etc/apt/sources.list.d/snijders-it.list apt-get updateStep 3: install nagios
During the following step the Nagios installation will ask you for a password for the user 'nagiosadmin'. Don't forget to use a strong password!
apt-get install nagios3 nagios3-core nagios3-doc \ nagios3-common nagios3-cgiStep 4: download and install mknagconf
This step downloads the latest version of the script and example configuration files from github. After downloading you can run the ./install.sh script to copy all files to the correct place. This script will overwrite the current nagios configuration from Step 3.
cd /usr/srcgit clone git://github.com/SnijdersIT/mknagconf.git cd mknagconf sudo ./install.shStep 5 (optional): setup local repo for configs
It's usually good to do nagios stuff in some kind of repository, an example would be:
cd /etc/nagios3git init git config --global user.name "your name" git config --global user.email you@example.net echo "conf.d/*_autogenerated.cfg" >> .git/info/exclude git add * git commit -am 'first nagios config'Step 6: edit the hosts.def definition file
Open the following file in your texteditor:
/etc/nagios3/definitions/hosts.defYou will see a line like:
hpserv;192.168.23.4;2001:db8:1::65;coregate;central HP server
Which will be interpreted as: host 'hpserv' with ipv4 address "192.168.23.4" and ipv6 address "2001:db8:1::65", has 1 parent namely: "coregate" and is also called the "central HP server".
The ipv6 address, parents and human name are optional. You can specify multiple parents if you separate them with a comma. Don't forget to create a line specifying the parent itself!
Remove the hpserv line and add a (dual-stack) host you would like to monitor. Define one host per line. In the next step you can define what services you want to monitor on that host.
Step 7: edit the services.def definition file
Open the following file in your texteditor:
/etc/nagios3/definitions/services.defYou will see a line like:
hpserv = ping, ping6, ftp, ssh6Which will be interpreted as: perform an IPv4 ping check, IPv6 ping check, an FTP connect over IPv4 and a SSH connect over IPv6 to host "hpserv". Define one host per line, and all services that should be checked on that host on the same line.
Step 8: configure correct contact
Open the following file and modify it according to your situation:
/etc/nagios3/conf.d/contacts.cfgStep 9: generate configuration, reload nagios
Change to the nagios3 configuration directory, run the make commands to clean up the auto-generated files, compile the nagios configurations from the definition files and check if the configurations makes any sense.
cd /etc/nagios3 make cleanmake make check && /etc/init.d/nagios3 reload git commit -am 'added my first hosts' # optional step
For more information open the various files in /etc/nagios3/definitions/ and read their headers. Further recommended reading: the README file in /usr/src/mknagconf/
If at some later point you want to add more hosts or delete old ones, just go through step 6, 7 and 9.
That's it! Have fun using Nagios :-)