Hits : 3458

Nagios :: Mini How To 


Nagios is an Open Source host, service and network monitoring program.

Contents


Nagios Installation


Below are simple steps to install nagios to our system.

Users / Groups


We must create a new user / group for nagios software.

# useradd nagios


Verify

# grep nagios /etc/passwd /etc/group
 
/etc/passwd:nagios:x:1001:1001::/home/nagios:/bin/sh
/etc/group:nagios:x:1001:


Next we must create a new group for nagios and apache user

# groupadd nagcmd
# usermod -G nagcmd nagios


The apache user can be defined by this:

# grep '^User ' /usr/local/apache2/conf/httpd.conf|cut -d' ' -f2
apache 
 
# usermod -G nagcmd apache


top

Nagios Installation


We should create the installation path and transfer the ownership tou user nagios

mkdir -pv /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios


Downloading the sources

wget -c http://heanet.dl.sourceforge.net/sourceforge/nagios/nagios-2.10.tar.gz
tar zxfv nagios-2.10.tar.gz
cd nagios-2.10


Configure & compile nagios

./configure
make all make install
make install-init
make install-commandmode
make install-config


If we want to use the sample confs from the nagios installation we should do this:

# cd /usr/local/nagios/etc/
# for i in `ls` ; do mv $i `echo $i | cut -d'-' -f1` ; done


top

Nagios-plugins


After we finished the nagios installation we should continue with the installation of nagios-plugin.
So we download the sources from below:

# wget -c http://heanet.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.10.tar.gz
# tar zxvf nagios-plugins-1.4.10.tar.gz


And we build nagios plugin :


# cd nagios-plugins-1.4.10
# ./configure LDFLAGS=-ldl
# make
# make install


top

Start Nagios


We can start nagios application by doing this :

# /etc/init.d/nagios start


top

Apache Virtual Host


if we want to setup apache, we simply add the below virtual host:

# cat > /usr/local/apache2/conf/nagios.conf << EOF
 
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
 
<Directory "/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
</Directory>
 
Alias /nagios /usr/local/nagios/share
 
<Directory "/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
</Directory>
 
EOF


And add at the apache conf httpd.conf file the below conf line:

# echo Include conf/nagios.conf >> /usr/local/apache2/conf/httpd.conf


top

Adding users to nagios web host


# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password: ******
Re-type new password: ******
Adding password for user nagiosadmin


top

Basic Configuration


Change configuration for nagios group to access / view the hosts

# vim /usr/local/nagios/etc/cgi.cfg
[ edit ] 
use_authentication=1
authorized_for_system_information=nagiosadmin
authorized_for_configuration_information=nagiosadmin
authorized_for_system_commands=nagiosadmin
authorized_for_all_services=nagiosadmin
authorized_for_all_hosts=nagiosadmin
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin
 
# /etc/init.d/nagios restart


top



/usr/local/apache2/bin/httpd -k restart
 
lynx http://localhost/nagios
 
username: nagiosadmin
password: **********


Verify Configuration

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
ps -ef | grep nagios
lynx http://localhost/nagios


top

fruity


http://fruity.sourceforge.net/

Groundwork Fruity is a PHP based web-frontend to your Nagios configuration

$ wget -c http://belnet.dl.sourceforge.net/sourceforge/fruity/fruity-1.0-rc2.tar.gz
$ tar zxvf fruity-1.0-rc2.tar.gz
$ cd fruity-1.0-rc2

top