Installing Nagios Core on CentOS 5 / 6 & 7
In this tutrial I will install Nagios Core (one of the most powerful and opensource NMS) with Nagios Plugins and NRPE on CentOS version 7, steps for CentOS 5 & 6 also included.
Tools / Addons used in this tutorial:
Operating System: CentOS 7
Nagios Core – http://www.nagios.org/download/core
Nagios Plugins – http://www.nagios.org/download/plugins
NRPE – http://exchange.nagios.org/directory/Addons/…..
Install Required Dependencies:
# yum install -y gcc gcc-c++ gd-devel gd png png-devel jpeg jpeg-devel zlib zlib-devel php mysql mysql-server mysql-devel make vim mailx wget httpd
For CENTOS 7:
# yum install -y gcc gcc-c++ gd-devel gd zlib zlib-devel php mariadb mariadb-server mariadb-devel make vim mailx wget mlocate httpd
Create Nagios Group & User:
# groupadd -g 9001 nagcmd
# useradd -u 9000 -g nagios -G nagcmd -d /usr/local/nagios -c “Nagios Admin” nagios
# passwd nagios //set password for nagios user…
Installing Nagios Core:
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz
# tar xzvf nagios-4.0.8.tar.gz
# cd nagios-4.0.8
# ./configure –sysconfdir=/etc/nagios –localstatedir=/var/nagios –with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconf
# chkconfig nagios on
# chkconfig httpd on
# systemctl enable httpd.service //CENTOS 7
# systemctl enable nagios //CENTOS 7
Installing Nagios Plugins:
# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
# tar xzvf nagios-plugins-2.0.3.tar.gz
# cd nagios-plugins-2.0.3
# ./configure –sysconfdir=/etc/nagios –localstatedir=/var/nagios
# make
# make install
Testing Nagios Plugins:
{{ if status OK, it means, plugins installed correctly}}
Installing NRPE:
We are installing NRPE on NMS server because we need nrpe check command script.
Installing Required Deps:
# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
# tar xzvf nrpe-2.15.tar.gz
# cd nrpe-2.15
# ./configure –enable-openssl
# make all
# make install-plugin
Creating Nagios Web Interface User Access File:
# htpasswd -cm htpasswd.users nagios //Enter password when asked, this will be password for nagios user
# chown apache htpasswd.users
# chmod 600 htpasswd.users
# chmod 755 -R /usr/local/nagios
# service nagios start
# service httpd restart
# systemctl restart httpd.service //CENTOS 7
Additionally:
# systemctl stop firewalld //CENTOS 7
# systemctl disable firewalld //CENTOS 7
# setenforce 0
Access Nagios Web Interface by entering following address in browser:
If you want to browse any other URL like /nms rather then /nagios:
– Set “Base_URL” to /nms/cgi-bin rather then /nagios/cgi-bin
Creating VirtualHost to: nms.muhammadattique.com
Add Following lines at last of the configuration file:
ServerAdmin mymail@muhammadattique.com
DocumentRoot /usr/local/nagios/share/
ServerName nms.muhammadattique.com
</VirtualHost>
Save Configuration file, restart Apache server and browse to:
Error in Log file:
Solution:
# cp /usr/local/nagios/sbin/statusjson.cgi /var/www/cgi-bin
# service httpd restart
Done.
Further: