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 the plugin:
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
# useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
tar zxvf nagios-4.0.1.tar.gz
Note: this Nagios version (4.0.1) has a bug in the map (statusmap.c). To solve this problem download and install the following patch before you start Nagios installation
Download the patch from this link:
http://tracker.nagios.org/view.php?id=470
Download the file: nagios-4-statusmap-2.patch
To apply the patch execute this command:
patch -p0 --verbose < patch_name
The patch fixes 2 files:
directory_nagios/cgi/statusmap.c
directory_nagios/common/objects.c
Even if this patch is for version 4.0.0, it also works for 4.0.1.
At first try the patch will fail, just manually enter the path to the source of nagios 4.0.1.
Now it is possible to install 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/eventhandlers/ /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
There is another bug in Nagios, namely in: /etc/init.d/nagios
you have to change everything with a "hack" code.
Download the code from this website and copy it inside /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 it is possible to start nagios
/etc/init.d/nagios start
You can create the admin user for nagios:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
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 running on the browser:
http://<your.nagios.server.ip>/nagios
This post is also available in: Italian