Feeds:
Posts
Comments

I use Nagios for daily monitoring network elements. It’s such a great monitoring tool, and guess what. It can also send notification when problem encountered with email, IM, SMS, etc.

How to install Nagios.

System Requirements:
Apache2
GD Library
Nagios (currently 3.0rc1 last time I downloaded it at 01/05/08)
Nagios Plugins (currently 1.4.11 last time I download it at 01/05/08)
Basic Compilers

Access Requirements:
Root Password

Special Commands:
Sudo (run root commands)

Preinstall
Open a terminal window by selecting Applications, Accessories, and Terminal.
1) Install Basic Compilers
Type ‘sudo apt-get install build-essential’.

2) Install GD Libraries
Type ‘sudo apt-get install libgd2-dev’. If it doesn’t work, type ‘sudo apt-get install libgd2-xpm-dev’.

3) Install Apache2
Type ‘sudo apt-get install apache2’.

4) Download Nagios 3x
Go to http://www.nagios.org and download the newest tarball to the desktop.

5) Download Nagios 1.4.x Plug-ins
Also available at http://www.nagios.org and download the newest tarball of the Nagios Plugins to the desktop.

6) Nagios Install
Within the terminal window type the following commands:
cd ~/Desktop
tar xzf nagios-3.0rc1.tar.gz
cd nagios-3.0rc1

adduser nagios (this is default, change for your usage if needed. Fill in information as needed (password, user information))
mkdir /etc/nagios (change for your usage if needed, take note of change this will be the install url)
chown nagios.nagios /etc/nagios
grep “^User” /etc/apache2/httpd.conf
/usr/sbin/groupadd nagcmd (default, change for your usage, take note of change)

Adds a group named nagcmd to Ubuntu for allowing external commands from the Web UI.

/usr/sbin/usermod –G nagcmd www-data (user for apache)

/usr/sbin/usermod –G nagcmd nagios (user for nagios)

./configure –prefix=/etc/nagios –with-cgiurl=/nagios/cgi-bin –with-htmurl=/nagios –with-nagios-user=nagios –with-nagios-group=nagios –with-command-group=nagcmd ( If you don’t change anything, just copy this)

(./configure –prefix=prefix –with-cgiurl=cgiurl –with-htmurl=htmurl –with-nagios-user=someuser –with-nagios-group=somegroup –with-command-group=cmdgroup
Replace prefix with /etc/nagios (unless urlschanged)
Replace cgiurl with /nagios/cgi-bin
Replace htmurl with /nagios (default)
Replace someuser with nagios (unless otherwise changed)
Replace somegroup with nagios (unless otherwise changed)
Replace cmdgroup with nagcmd (unless otherwise changed)
Verify general options look accurate)

make all
make install
make install-init (creates /etc/init.d/nagios functionality)
make install-commandmode (creates permissions for folders)
make install-config (creates sample config files)

7) Install Nagios Plugins
Within the terminal window type the following commands:
cd ..
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11

./configure –prefix=/etc/nagios –with-cgiurl=/nagios/cgi-bin

(./configure –prefix=prefix –with-cgiurl=someurl
Replace prefix with /etc/nagios (unless urls changed)
Replace cgiurl with /nagios/cgi-bin)

make
make install
make install-root

8 ) Configure Apache
Within the terminal window type the following commands:
sudo gedit /etc/apache2/httpd.conf

Once file opens, paste in the following lines:

ScriptAlias /nagios/cgi-bin /etc/nagios/sbin

<Directory “/etc/nagios/sbin”>
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /etc/nagios/etc/htpasswd.users
Require valid-user
</Directory>

Alias /nagios /etc/nagios/share

<Directory “/etc/nagios/share”>
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName “Nagios Access”
AuthType Basic
AuthUserFile /etc/nagios/etc/htpasswd.users
Require valid-user
</Directory>

Change the folder urls with information used above if changed, save and close.

/etc/init.d/apache2 restart
htpasswd –c /etc/nagios/etc/htpasswd.users nagiosadmin (if this does not work, use cd /etc/nagios/etc; htpasswd -c htpasswd.users nagiosadmin)

Replace nagiosadmin if required.
Enter in a password which will be used for Web UI

I’m using Ubuntu in VMware, so don’t forget to change the network address to localhost.
more /etc/hosts
ifconfig lo 127.0.0.1 netmask 255.0.0.0

in terminal
sudo gedit /etc/apache2/httpd.conf

add the line:
ServerName localhost

save the file.

then in terminal:
sudo /etc/init.d/apache2 restart

9) Setup User Access in Nagios
In the terminal type the following commands:
/etc/nagios/bin/nagios –v /etc/nagios/etc/nagios.cfg (unless urls changed)

This should return clean at this point.

ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios ( for auto start)

/etc/init.d/nagios restart

10) Try Nagios on web browser
Open your web browser and enter the url: http://localhost/nagios/

Voila!

Now, you can try to play around and have some fun with Nagios 🙂 .

Considering I ‘ve installed Nagios at VMware, you might have some problem with Apache.

Try to shutdown VMware, close it. And try it again. Hope it can help.

Thanks to ubuntu forum ! gosh..I should save that post..Anyway thanks to cavern,-jon !

Advertisements