Walker News

How To Install Nagios On Redhat Linux In 3 Minutes?

Nagios is an enterprise-class open source computer/network monitoring software with on-going enhancements from its vibrant community made up of worldwide supporters.

Unless there is no internal resources to support this open source IT infrastructure monitoring system, Nagios Core is free for everyone and “easy” to use by average system administrators who willing to look for reference from the Net!

This guide, for example, is done with reference from the official Fedora Quickstart documentation:
This reference is tested on RHEL 5.2 using Nagios Core 3.2.3 and should be good for people who are interested to install Nagios on Redhat Linux/RHEL, Fedora, or CentOS. Users with “basic” knowledge of using Linux should have no problem to execute this plan :)

Login as root (forget about sudo for simplicity) and confirm you’ve these required software (GCC compiler, GD libraries, httpd, PHP) prior to compile and install Nagios:
rpm -qa | grep -e ^httpd -e ^php -e ^gcc -e ^gd- | sort

Create user account and group ID for running Nagios:
useradd -m nagios
passwd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache

Download the latest Nagios Core and Nagios Plugins source files. If the server can access to Internet directly, just uses wget to download (the latest versions at this time of writing):
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz

Now, we are going to compile and install the Nagios core. Firstly, extract the source files from the gzipped tarball:
tar -zxvf nagios-3.2.3.tar.gz
cd nagios-3.2.3
From next execution onwards, you may use tee command to duplicate output to a file for examination, which could be useful to trace errors that triggered when compiling source code.

Run the Nagios configure script to use nagcmd group explicitly:
./configure --with-command-group=nagcmd

Compile the Nagios source code (piping to tee command is optional, as said earlier):
make all | tee make_all.nagios_core.log

Install the compiled binaries of Nagios Core, init script, sample config files and set permissions on the external command directory:
make install
make install-init
make install-config
make install-commandmode

Edit contact.cfg file to update email address of nagiosadmin for receiving alerts (See how to relay email from Linux (Nagios) to Exchange Server):
vi /usr/local/nagios/etc/objects/contacts.cfg

Install Nagios web config file to Apache conf.d directory:
make install-webconf

Create an user account for logging into the Nagios web interface:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache (httpd) to make the new settings take effect:
service httpd restart

Add Nagios to Redhat Linux system services and configure it to start up automatically when RHEL boots into runlevel 3, 4, and 5:
chkconfig --add nagios
chkconfig --level 345 nagios on

Now, you need to install standard Nagios plugins which are used to monitor various computer/network status. So, let’s unpack the compressed Nagios Plugins tarball file:
tar -zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15

Run configure file to explicitly set ownership to nagios:nagios respectively:
./configure --with-nagios-user=nagios --with-nagios-group=nagios

Ready to compile and install Nagios Plugins binary files:
make
make install

Verify the sample Nagios configuration files (the files used to define how and what services or hosts to monitor by Nagios Core via the various plugins):
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Phew! No error found and thus should be OK to start up Nagios for the first time:
service nagios start

Now, the Nagios server is up and running to monitor the local computer system status. Try to access the Nagios web interface via this URL (using nagiosadmin ID and password created in earlier step):
http://<nagios_server_ip>/nagios

In the next post, I will show you how to compile and install NRPE on remote Linux hosts and configure Nagios Core (server) to start monitoring remote Linux servers via NRPE.

Custom Search

  1. Walker 20-03-11@18:29

    Mmm…it takes more than 3 minutes to complete this exercise, and it is longer when compiling source codes on average hardware :(

  2. dario 25-01-13@21:10

    If after installing you have an error (caused by SELinux), please try this following command:

    chcon -R -t httpd_sys_content_t /usr/local/nagios
    

    Thank you for this useful post!

2016  •  Privacy Policy