Nagios, now known as Nagios Core, is a free and open source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.
Nagios is available in two versions, Nagios Core and Nagios XI. Nagios Core is free, and Nagios Xi has many features, and which is not free. You can compare and download of both versions in this link.
In this blog we will cover how to install and configure Nagios Core 4.4.3 on CentOS 7.
Install & Configure Nagios Core
Once you install and configure your Operating system install the below dependencies like Apache, PHP, SNMP etc
#yum install httpd php php-cli gcc unzip wget glibc glibc-common gd gd-devel net-snmp
Start the Apache service and add same to startup by executing below command
#systemctl start httpd #chkconfig httpd on
Now create a new nagios user account and setup a password to this account
#useradd nagios #passwd nagios
Now create a groud for nagios setup “nagcmd” and add nagios user to this group. Also add nagios user in apache group
#groupadd nagcmd #usermod -a -G nagcmd nagios #usermod -a -G nagcmd apache
After installing required dependencies and adding user accounts and groups. Let’s start with Nagios core installation.
#cd /opt/ #wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.3.tar.gz #tar xzf nagios-4.4.3.tar.gz #cd nagios-4.4.3 #./configure --with-command-group=nagcmd #make all #make install #make install-init #make install-daemoninit #make install-config #make install-commandmode #make install-exfoliation
Now use below command to setup Apache configuration for Nagios installation.
Now setup apache authentication for user ngiosadmin. Do not change this username. else you would require more changes in configuration.
#htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now restart Apache service to make the new settings take effect.
#systemctl restart httpd
After installing and configuring Nagios core service, download latest nagios-plugins source and install using following commands.
#cd /opt #wget http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz #tar xzf nagios-plugins-2.2.1.tar.gz #cd nagios-plugins-2.2.1
Now compile and install nagios plugins
#./configure --with-nagios-user=nagios --with-nagios-group=nagios #make #make install
You have completed the installation now, First, verify the Nagios configuration file using the following command
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
If there are not error, let’s start the Nagios service
#systemctl restart nagios
Execute the below command to start nagios services and add in startup
#systemctls start nagios #chkconfig nagios on
Nagios creates its own apache configuration file /etc/httpd/conf.d/nagios.conf. There is no need to make any changes to it. Simply open below URL in browser.
http://FQDN or IP Address/nagios/
Provide Apache authentication Username & Password we created while installation
If you have any comments, please drop me a line