Install Nagios on Ubuntu
The following is a guide to install Nagios Core on an Ubuntu machine.
Preparing for the Installation
First you will need to be root;
1 |
sudo -s |
For convenience it is best to install ssh and vim;
1 |
apt-get install ssh vim |
Now you need to install some pre-requisites required for Nagios to correctly install/run;
1 |
apt-get install apache2 |
1 |
apt-get install libapache2-mod-php5 |
1 |
apt-get install build-essential |
1 |
apt-get install libgd2-xpm-dev |
1 |
1 |
apt-get install libssl-dev |
Now add the user ‘nagios’ to the system;
1 |
/usr/sbin/useradd -m -s /bin/bash nagios |
1 |
passwd nagios |
Create nagcmd group to allow commands through the web;
1 |
/usr/sbin/groupadd nagcmd |
1 |
/usr/sbin/usermod -a -G nagcmd nagios |
1 |
/usr/sbin/usermod -a -G nagcmd www-data |
Installing Nagios and the Plugins
First, make a directory to download the plugins to
1 |
mkdir ~/downloads |
1 |
1 |
cd ~/downloads |
Now you need to download Nagios and Nagios plugins;
1 |
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz |
1 |
1 |
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagiosplugins-1.4.16.tar.gz |
Extracting Nagios so it can be compiled/installed;
1 |
cd ~/downloads |
1 |
tar -zxvf nagios-3.4.1.tar.gz |
1 |
cd nagios |
Now you must run the install script and compile the source code;
1 |
./configure --with-command-group=nagcmd |
1 |
1 |
make |
1 |
1 |
make all |
1 |
1 |
make install |
1 |
1 |
make install-init |
1 |
1 |
make install-config |
1 |
1 |
make install-commandmode |
Run the following command to install the web server
1 |
make install-webconf |
The next step is to create a password for the nagios web server login account, ‘nagiosadmin’
1 |
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin |
Remember this password as it is required to log on to the web interface.
Restart apache to apply the changes
1 |
/etc/init.d/apache2 reload |
Now you must extract the plugins;
1 |
cd ~/downloads |
1 |
tar -zxvf nagios-plugins-1.4.16.tar.gz |
1 |
1 |
cd nagios-plugins-1.4.16 |
Use the commands below to compile and install the plugins
1 |
./configure --with-nagios-user=nagios --with-nagios-group=nagios |
1 |
make |
1 |
make install |
Now configure Nagios to start on system start
1 |
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios |
Check the nagios configuration with the following command
1 |
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg |
Make note of this command, it is very important later on for debugging issues with config files.
If there are no errors, you are ready to start Nagios;
1 |
/etc/init.d/nagios start |
Now access the web interface from a web browser, navigating to
http://localhost/nagios/
or from within the network;
http://<hostname/ip>/nagios/
Congratulations, you are now done with the installation!
Please refer to our blog for a post on configuring your first host.
Tags: monitoring, nagios, sysadmin