Nagios Test VLAN

Introduction

Official website
Nagios® is an Open Source host, service and network monitoring program. In this guide nagios version 3.02 is used on a machine running centos 5.1.Nagios is a web-based application that use CGI commands to check the status of the whole system. Including hardwares such as servers and routers, and services like ssh or FTP
 
The guide for installing and configuring nagios, the reference is at http://nagios.sourceforge.net/docs/3_0/


Installation

Nagios is a web based application, therefore it has too run in a server with apache and cgi-bin enabled. If nagios need to be managesd remotely, the relavent firewall ports should be open on the machine. Develop environment is needed if nagios is compilied from source package.
 
The nagios package is not in the centos official repository currently. In this guide it is compiled from source. Nagios depends on apache and gd-devel package to compile, make sure these pakages are installed along with the compiling environment.

And user & groups for nagios

There's a user and two groups should be added to the system running nagios. They are the nagios user for running nagios service and nagcmd group  to excute external commands using apache which contains the nagios user and apache user.
 
groupadd nagios
groupadd nagcmd
useradd -g nagios nagios
passwd nagios
usermod -G nagcmd nagios
usermod -G nagcmd apache
 

Compiling and installing nagios

Download nagios and nagios-plugin source package from nagios website (www.nagios.org)
Extract the source packages, go to the nagios folder in terminal and use following commands to compile and install nagios:
 
./configure --with-command-group=nagcmd
make all
make install-init
make install-config
make install-commandmode
make install-webconf
 
Configure the email address of the nagiosadmin in the configuration file.
 
vi /usr/local/nagios/etc/objects/contacts.cfg
 
Change the email address associated with the nagiosadmin contact definition to the appropriate email address.
 
next create a nagiosadmin account for logging into the Nadios web interface:
 
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
 
it will prompt for entering a password.
 
restart apache server:
 
service httpd restart
 
The next step is to install nagios plugins. Go to the folder contain the extracted source code for nagios plugins and type the following command:
 
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
 
Now it's time to add nagios to the list of system services and make it start automatically at startup:
 
chkconfig --add nagios
chkconfig nagios on
 
Verify the sample nagios configuration file by
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
 
if no errors are found start the nagios service by
service nagios start
 
Next the SElinux mode of the centos system should be changed to permissive, this can be done by adjust the setting at the System ->Administration->Security Level and Firewall in the graphical user interface or by changing settings in /etc/selinux/config
 
If the SElinux needs to run in enforcing mode, the following command should be used to allow nagios access system infomation:
chcon -R -t httpd_sys_content_t /usr/local/nagios/sbin
chcon -R -t httpd_sys_content_t /usr/local/nagios/share
 
Now Nagios web interface should be accessible at http://localhost/nagios, login use the nagiosadmin account created in the previous step. Adjust firewall settings if the web portal needs to be accessed remotely.
 
Now the basic installation of nagios that can monitor local host is completed.
Comments