Tuesday, July 17, 2007

Installing and running Nagios

Download latest & stable nagios from here. Select the tarball
Download
Also download the plugins

Here these steps have been performed on Fedora 2 and Fedora5 using the nagios-2.9 and nagios-plugin-1.4.9.

Add one user nagios and one group nagcmd
$adduser nagios
(There is no need of assigning password to this user as this user is not going to login to the
system)
$groupadd nagcmd

Add user nagios and web server user apache to this group
(To know who is the owner of web server
$grep "^User" /etc/httpd/conf/httpd.conf
)

$usermod -G nagcmd nagios
$usermod -G nagcmd apache

$cd /usr/local/
Create one dir to hold all the nagios files
$ mkdir nagios
Change ownership of this dir to nagios
$chown -R nagios:nagios nagios

Untar the downloaded nagios tar file
$tar -xzf nagios-x.x.tar.gz

It will create one dir nagios-x.x inside the /usr/local
$cd nagios-x.x/

Configure the nagios and install
$./configure --prefix=/usr/local/nagios --with-cgiurl=/nagios/cgi-bin --with-htmurl=/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-group=nagcmd
$make all
$make install
$make install-init
$make install-commandmode
$make install-config

Installing Plugins
$ cd /usr/local

Untar the downloaded nagios plugin
$tar -xzf nagios-plugins-1.x.x.tar.gz
$cd nagios-plugins-1.x.x/

Configure the nagios plugin, and install plugins
$./configure --prefix=/usr/local/nagios

$make
$make install

Plugins will be installed at
/usr/local/nagios/libexec

Setup The Web Interface

Configure Aliases and Directory Options For The Web Interface
Add these line (at last) in the httpd.conf file (at /etc/httpd/conf dir)

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin



Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user


Alias /nagios /usr/local/nagios/share


Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user


Restart the webserver
$ /etc/init.d/httpd restart

Configure Web Authentication
$htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

(Enter the password)

Rename the config sample file
Nagios creates sample configurtion files at /usr/local/nagios/etc
Rename these files
$cd /usr/local/nagios/etc
$mv nagios.cfg-sample nagios.cfg
...and so on

Start nagios
$/etc/init.d/nagios start

After changing any config file check the main nagios.config
$ /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

It will display any syntax error in any config file with file name and line number, rectify the errors and reload the nagios.

$/etc/init.d/nagios reload

Point your browser at:

http://localhost/nagios

It will ask for apache authentication, supply the user: nagiosadmin and password

No comments:

Whats new in Ajuby 0.5