Nagios, Nconf and Nrpe on Debian/Ubuntu part 1/3

Environment: The only requirement for this guide is to have a debian or ubuntu

Install the necessary packages: apt-get install wget build-essential apache2 php5-gd wget libgd2-xpm libgd2-xpm-dev libapache2-mod-php5

download nagios and plugins:

wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.0.1/nagios-4.0.1.tar.gz
# wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
cd nagios-4.0.1
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
tar zxvf nagios-4.0.1.tar.gz

warning: this version of nagios (4.0.1) has a bug in the map section (statusmap.c). To fix it download the following patch and install it

before starting the installation of nagios.

Download the patch from this link:

http://tracker.nagios.org/view.php?id=470

get the file: nagios-4-statusmap-2.patch

To apply the patch run this command:

patch -p0 --verbose < patch_name

the patch fixes 2 files: nagios_directory/cgi/statusmap.c nagios_directory/common/objects.c

Even though the patch is for version 4.0.0, it also works for 4.0.1.

When you get a path error, manually enter the nagios source path.

After applying the patch we proceed with the configuration and installation of nagios:

cd nagios-4.0.1

./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-mail=/usr/bin/sendmail

make all
make install
make install-init
make install-config
make install-commandmode
make install-webconf

cp -R contrib/evenhandlers/ /usr/local/nagios/libexec/
chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 

Another bug in nagios and precisely in /etc/init.d/nagios

you need to change the whole file with a “hack” code.

download the code from this site and copy it in place of /etc/init.d/nagios

http://support.nagios.com/forum/viewtopic.php?f=7&t=12038&start=20#p64091

Install daemon

apt-get install daemon

now you can start nagios

/etc/init.d/nagios start

now create the user for nagios:

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Let’s move on to the plugin:

apt-get install libssl-dev

tar zxvf nagios-plugins-1.5.tar.gz

cd nagios-plugins-1.5

./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make
# make install

ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Now if everything went well you should have your nagios working in your browser:

http://<your.nagios.server.ip>/nagios