Wednesday , December 19 2018
Home / Network Admin / Installing Nagios Core on CentOS

Installing Nagios Core on CentOS

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:

For CentOS 5/6:

# 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 9000 nagios
# 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:

# cd /usr/local/src
# 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:

# cd /usr/local/src
# 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:

# /usr/local/nagios/libexec/check_icmp -H <TargetIP>

1- Nagios Plugins Test  Installing Nagios Core on CentOS 1 Nagios Plugins Test

 {{ 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:

# yum install openssl-devel -y
# cd /usr/local/src
# 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:

# cd /etc/nagios
# 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:

# service iptables stop
# systemctl stop firewalld                                 //CENTOS 7
# systemctl disable firewalld                                 //CENTOS 7
# setenforce 0

Access Nagios Web Interface by entering following address in browser:

http://<ServerIP>/nagios

If you want to browse any other URL like /nms rather then /nagios:

# vim /usr/local/nagios/share/config.inc.php

– Set “Base_URL” to /nms/cgi-bin               rather then              /nagios/cgi-bin

 

2- Nagios Access  Installing Nagios Core on CentOS 2 Nagios Access

 

Creating VirtualHost to:              nms.muhammadattique.com

#   vim /etc/httpd/conf/httpd.conf

Add Following lines at last of the configuration file:

<VirtualHost *:80>
ServerAdmin mymail@muhammadattique.com
DocumentRoot /usr/local/nagios/share/
ServerName nms.muhammadattique.com
</VirtualHost>

Save Configuration file, restart Apache server and browse to:

http://nms.muhammadattique.com

Error in Log file:

 script not found or unable to stat: /var/www/cgi-bin/statusjson.cgi, referer: http://nms.muhammadattique.com/main.php

Solution:

# mkdir /var/www/cgi-bin

# cp /usr/local/nagios/sbin/statusjson.cgi /var/www/cgi-bin

# service httpd restart

Done.

 

Further:

–     Adding Linux/Unix host in Nagios Core for Monitoring

–     Adding Windows host in Nagios Core for Monitoring

About Muhammad Attique

Check these out :)

How to Modify GRUB Bootloader version 2

I’m going to show you how can we edit and modify GRUB Bootloader version 2, …

Leave a Reply

Your email address will not be published. Required fields are marked *