Connect & Share

Installing Nagios

Nagios is a host and service monitor designed to inform you of network problems before your clients, end-users or managers do. It has been designed to run under the Linux operating system. Nagios is a powerful tool that provides you with instant awareness & automatically fix problems when they are detected, it will monitor your entire infrastructure, service checks are scheduled in certain situations it’s very, very stable and, if you set it up right, pretty easy to maintain Installation of Nagios Today, We will learn installation of the Nagios. Nagios is best monitoring tools and nagios offers monitoring and alerting for servers, switches, application, and services. It alerts users when things go wrong and alerts them again when the problem has been resolved. Let’s start installation of nagios : Nagios XI - Hardware Requirements
Monitored Nodes /Hosts	Monitored Services 	Hard Drive Space 	CPU Cores 	RAM
50 				250 			40 GB 			1 – 2 		1 – 4GB
100 				500 			80 GB 			2 – 4 		4 – 8GB
>500				>2500 			120 GB 			>4 		> 8 GB
Supported Distributions Nagios XI is currently supported with the following Linux distributions for both 32 and 64 bit installations: CentOS 5/6 RHEL 5/6 Server requirement for nagios Fresh Running Linux server that has network access and a C compiler installed. You will need to have the following software installed. 1. A web server (preferrably Apache) 2. gd library version 1.6.3 or higher Nagios will be configured to monitor a few aspects of your local system (CPU load, disk usage, etc.) The Nagios web interface will be accessible at http://localhost/nagios/ Prerequisites:- During portions of the installation you will need to have root access to your machine. Make sure you’ve installed the following packages on your OS installation before continuing. • Apache • PHP • GCC Compiler • GD Development Libraries You can use YUM to install these packages by running the following commands (as root):
yum install httpd php
yum install gcc glibc glibc-common
yum install gd gd-devel
After Confirm all above things then you can start the process for installation of nagios First we will create user for nagios : 1] Create Account Information: Become the root user Su –l Create a new nagios user account and give it a password.
/usr/sbin/useradd –m nagios
Passwd nagios
Create a new nagcmd group for allowing external commands to submitted through the web interface. Add both the nagios user and the apache user to the group.
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod –a –G nagcmd nagios
/usr/sbin/usermod –a –G nagcmd apache
After user and group create then you need to download the nagios script. 2] Download Nagios and the plugins Create a directory for storing the download.
mkdir ~/downloads
cd ~/downloads
Download the source code tarballs of both Nagios and the Nagios plugins (visit links and download the latest version of nagios). These directions were tested with nagios-3.4.2 and Nagios Plugins 1.4.16. After download the both application we will start to install it 3] Compile and Install Nagios Extract the Nagios source code tarball.
cd ~/downloads
tar –xzf nagios-3.x.x.tar.gz
cd nagios-3.x.x
Run the nagios configure script, passing the name of the group you created earlier like :
./configure –with-command-group=nagcmd
Compile the nagios source code : make all Install binaries, init script, sample config files and set permissions on the external command directory.
make install
make install-init
make install-config
make install-commandmode
Don’t start Nagios yet because of there is still more that needs to be done… 4] Customize Configuration : Sample configuration files have now been installed in the /usr/local/nagios/etc directory. These sample files should work fine for getting started with Nagios. You’ll need to make just one change before you proceed… Edit the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor and change the email address associated with the nagiosadmin contact definition to the address you’d like to use for receiving alearts.
vi /usr/local/nagios/etc/object/contacts.cfg
5] Configure the web interface : Install the nagios web config file in the apache conf.d directory.
make install-webconf
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account because of you will need it later.
htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
OR If htpasswd command is not working then use below step for htpasswd :
cd /usr/local/apache/bin
./htpasswd –c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Restart apache to make the new setting take effect.
/etc/init.d/service httpd restart
Service httpd restart
Note : Consider implementing the enhanced CGI security measures described here to ensure that your web authentication credentials are not compromised. 6] Compile and install the Nagios Plugins Extract the nagios plugins source code tarball.
Cd ~/downloads
Tar xzf nagios-plugins-1.x.x.tar.gz
Cd nagios-plugins-1.x.x
Compile and install the plugins.
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make install
7] Start Nagios Add nagios to the list of system services and have it automatically start when the system boots.
chkconfig –add nagios
chkconfig nagios on
verify the sample nagios configuration files.
/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg
If there are no errors, start Nagios.
Service nagios start
8] Modifiy SELinux Settings : Centos with SELinux installed and in Enforcing mode by default. Thins can result in “Internal Server Error” Messages when you attempt to access the Nagios CGIs. See if SELinux is in Enforcing mode.
put SELinux into Permissive mode.
Setenforce 0
To make this change permanent, you will have to modify the settings in /etc/selinux/config and reboot. Instead of disabling SELinux or setting it to permissive mode, you can use the following command to run the CGIs under SELinux enforcing/targeted mode :
chcon –R –t httpd_sys_content_t /usr/local/nagios/sbin/
chcon –R –t httpd_sys_content_t /usr/local/nagios/share
9] Login to the Web Interface : You should now be able to access the Nagios web interface at the URL below. You will be prompted for the username (nagiosadmin) and password you specified earlier.
click on the “service details” navbar link to see details of What’s being monitored on your local machine.

Leave a Reply