Nagios is an awesome Open Source monitoring tool, its provides you more comprehensive monitoring environment to always keep an eye on your all machines / networks whether you are in a data center or just your small labs.
With Nagios, you can monitor your remote hosts and their services remotely on a single window. It shows warnings and indicates if something goes wrong in your servers which eventually help us to detect some problems before they occur. It helps us to reduce downtime and business losses.
Recently, Nagios released its latest versions Nagios 4.2.0 and its latest stable release of Nagios plugins 2.1.2 on August 01, 2016.
- Monitor your entire IT infrastructure.
- Identify problems before they occur.
- Know immediately when problems arise.
- Share availability data with stakeholders, hypothetical question
- Detect security breaches.
- Plan and budget for IT upgrades.
- Reduce downtime and business losses.
Before we start installing nagios, server should have apache to be configured. To make sure apache (httpd) install, please try following commends,
# rpm –qa | grep httpd
If you found apache is installed, then start the service using below commends. Or follow this link to install and configure apache in Redhat 7
# systemctl status httpd.service
# systemctl start httpd.service (if service is not running use this comment to start)
Once make sure apache install, need to install some dependency packages before install nagios. To install;
# yum install gd gd-devel gcc glibc glibc-common wget make net-snmp –y
Create a User:
Once install required dependancies, now let create separate user and group for nagios to maintain the service,
# useradd nagios
# groupadd nagioscmd
Now add user nagios and apache to the nagioscmd group
# usermod -G nagioscmd nagios
# usermod -G nagioscmd apache
Install Nagios Core and Nagios Plugin
To install Nagios, we need to download package in tar and install it, here is the steps to install and the nagios core and nagios plugin,
# cd /opt/
# tar –xvf nagios-4.2.0.tar.gz
# ./configure –with-command-group=nagioscmd
# make all
# make install
# make install-init
# make install-config
# make install-commandmode
# make install-webconf (for setup apache configuration for nagios installation)
Once installed nagios core, we need to setup apache authentication for user nagiosadmin (you can keep any user, if you are giving your own user make sure you are giving correct user in further configurations)
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Once setup password, restart the apache service.
# systemctl restart httpd.service
Install nagios Plugin:
To download nagios Plugin;
# tar -xvf nagios-plugins-2.1.2.tar.gz
# cd nagios-plugins-2.1.2
# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
# make install
Update Alert Email Addres:
Open the “contacts.cfg” file with your choice of editor and set the email address associated with the nagiosadmin contact definition to receiving email alerts.
# vi /usr/local/nagios/etc/objects/contacts.cfg
To Verify Nagios Installation:
Use the following commands to verify nagios install,
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
To start a service
# systemctl start nagios.service
If you got any failure alert like “Error: Unable to write to check_result_path (‘/usr/local/nagios/var/spool/checkresults’) – No such file or directory”, this is due to there is /usr/local/nagios/var/spool/checkresults folder is not exist, so please create and restart the service it will start
To enable service while boot,
# systemctl enable nagios.service
To access nagios on web, in browser use http://<your-IP-Address>/nagios. You will get welcome screen like below