Required Packages
Make sure you've installed all the dependencies I have listed below,
- Apache 2
- PHP
- GCC compiler and development libraries
- GD development libraries
You can install above dependencies on your Ubuntu by running following commands,
sudo apt-get install apache2 libapache2-mod-php5 build-essential
Ubuntu 6.10 or earlier versions install the gd2 library using follwoing command,
sudo apt-get install libgd2-dev
Ubuntu 7.10 or later versions install the gd2 library using follwoing command,
sudo apt-get install libgd2-xpm-dev
Nagios account Information
How to become a root user.
sudo -s
Create a new nagios user account and set password.
/usr/sbin/useradd -m -s /bin/bash nagios
passwd nagios
you will need to add a nagios group. No need to follow this step Ubuntu 7.10 or latter versions,
/usr/sbin/groupadd nagios
/usr/sbin/usermod -G nagios nagios
Create a new nagcmd group and add both nagios and apache user,
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd www-data
Download Nagios 3.2.3 and the Plugins 1.4.15
mkdir ~/downloads
cd ~/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
wget http://sourceforge.net/projects/net-snmp/files/net-snmp/5.7.1/net-snmp-5.7.1.tar.gz/download
Compile and Install Nagios 3.2.3
cd ~/nagios
tar xzf nagios-3.2.3.tar.gz cd nagios-3.2.3
./configure --with-command-group=nagcmd make all
Don't forget to run following commands,
make install make install-init make install-config make install-commandmode
Nagios Server has been installed but Don't start Nagios Server yet.
Customize Configuration
nano /usr/local/nagios/etc/objects/contacts.cfg
Configure the Web Interface
Install the Nagios web config file in the Apache conf.d directory.
make install-webconf
Create Nagios Admin user for login to web interface and set the password up. (don't forget this password)
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restar apache server for make changes,
/etc/init.d/apache2 reload
/etc/init.d/apache2 reload
Compile and Install the Nagios Plugins
you must be needed to install net-snmp plugin before install the nagios-plugins-1.4.15,
cd ~/nagios
tar xzf net-snmp-5.7.1.tar.gz
cd net-snmp-5.7.1
./configure
make
make install
cd ~/nagios
tar xzf nagios-plugins-1.4.15.tar.gz cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
Start Nagios
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
Verify the sample Nagios configuration files before you start nagios server,
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Go and start your Nagios server,
sudo /etc/init.d/nagios start
Login to the Web Interface
http://localhost/nagios/
Errors and Solutions
Error 1:
"Externel command error: /usr/local/bin/snmpget: error while loading shared libraries: libnetsnmp.so.30: cannot open shared object file: No such file or directory"
sudo /etc/init.d/nagios restart
Solution1:
Copy libnetsnmp.so.30 file into Ubuntu libraries
cp /usr/loacl/lib/libnetsnmp.so.30 /usr/lib/libnetsnmp.so.30
Error 2:
"check_mrtgtraf: Unable to open MRTG log file"
Solution 2:
Make sure you set correct .log path into /usr/local/nagios/etc/object/switch.cfg
Each and every command which I have mentioned tested on my Ubuntu 11.10 and it worked for me.
Hope this help to you...!!!