Install & Configure Nagios Core 4.2 on CentOS 6 - CentLinux

Latest

Thursday, 18 August 2016

Install & Configure Nagios Core 4.2 on CentOS 6

Install & Configure Nagios Core 4.2 on CentOS 6

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 Core is the monitoring and alerting engine that serves as the primary application around which hundreds of Nagios projects are built.

In this article, we will setup a network monitoring server by installing Nagios Core 4.2 on a preconfigured CentOS 6 machine.

Before moving forward, it is required to have basic concepts of Nagios Core 4. Therefore, it is highly recommended that you should have Learning Nagios - Third Edition. It will be really helpful for you during your Nagios journey.

 

This Article Provides:

     

    System Specification:

    Nagios Core 4.2 does not have any specific system requirements except it requires a Linux 5/6/7 Server. Therefore, we have setup a virtual machine with the following specification:

    • CPU - 2.4 Ghz (2 cores)
    • Memory - 1 GB
    • Storage - 20 GB
    • Swap - 2 GB
    • Operating System - CentOS 6.7

     

    Installing Nagios Core 4.2 on CentOS 6:

    Verify kernel version and network configurations.

    [root@nagios01 nagios-plugins-2.1.2]# uname -a Linux nagios01.test.local 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux [root@nagios01 nagios-plugins-2.1.2]# ip addr 1: lo: mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether 00:0c:29:c6:33:f9 brd ff:ff:ff:ff:ff:ff inet 192.168.79.139/24 brd 192.168.79.255 scope global eth0 inet6 fe80::20c:29ff:fec6:33f9/64 scope link valid_lft forever preferred_lft forever [root@nagios01 nagios-plugins-2.1.2]#

    Install required packages using yum.

    [root@nagios01 ~]# yum install -y make net-snmp httpd php gcc glibc glibc-common gd gd-devel wget unzip

    Create User and Group for Nagios.

    [root@nagios01 ~]# useradd nagios [root@nagios01 ~]# groupadd nagcmd

    Add users to nagcmd group.

    [root@nagios01 ~]# usermod -G nagcmd nagios [root@nagios01 ~]# usermod -G nagcmd apache

    Create a directory to download Nagios packages.

    [root@nagios01 ~]# mkdir -p /soft/nagios [root@nagios01 ~]# cd /soft/nagios

    Download Nagios Core 4.2 and Nagios Plugins 2.1 tarballs from https://www.nagios.org/.

    [root@nagios01 nagios]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.2.0.tar.gz [root@nagios01 nagios]# wget https://nagios-plugins.org/download/nagios-plugins-2.1.2.tar.gz

    Extract downloaded tarballs.

    [root@nagios01 nagios]# tar -xvf nagios-4.2.0.tar.gz [root@nagios01 nagios]# tar -xvf nagios-plugins-2.1.2.tar.gz

    Compile and install Nagios Core.

    [root@nagios01 nagios]# cd /soft/nagios/nagios-4.2.0 [root@nagios01 nagios-4.2.0]# ./configure --with-command-group=nagcmd [root@nagios01 nagios-4.2.0]# make all [root@nagios01 nagios-4.2.0]# make install [root@nagios01 nagios-4.2.0]# make install-init [root@nagios01 nagios-4.2.0]# make install-commandmode [root@nagios01 nagios-4.2.0]# make install-config [root@nagios01 nagios-4.2.0]# make install-webconf

     

    Configure Nagios Core 4.2 on CentOS 6:

    Open contact.cfg file in vi editor.

    [root@nagios01 nagios-4.2.0]# vi /usr/local/nagios/etc/objects/contacts.cfg

    and change the email address of nagiosadmin with your email address to receive notifications.

    define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email ahmer_mansoor@hotmail.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** }

    Nagios Core does not provide any authentication method, therefore we are required to setup Basic HTTP Authentication for Nagios web interface.

    [root@nagios01 nagios-4.2.0]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

    Start httpd service and enable it on runlevel 3 and 5.

    [root@nagios01 nagios-4.2.0]# service httpd start [root@nagios01 nagios-4.2.0]# chkconfig --level 35 httpd on

    Compile and install Nagios Plugins.

    [root@nagios01 nagios-4.2.0]# cd /soft/nagios/nagios-plugins-2.1.2 [root@nagios01 nagios-plugins-2.1.2]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios [root@nagios01 nagios-plugins-2.1.2]# make [root@nagios01 nagios-plugins-2.1.2]# make install

    Verify Nagios configurations.

    [root@nagios01 nagios-plugins-2.1.2]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.2.0 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 08-01-2016 License: GPL Website: https://www.nagios.org Reading configuration data... Read main config file okay... Read object config files okay... Running pre-flight check on configuration data... Checking objects... Checked 8 services. Checked 1 hosts. Checked 1 host groups. Checked 0 service groups. Checked 1 contacts. Checked 1 contact groups. Checked 24 commands. Checked 5 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths... Checked 1 hosts Checked 0 service dependencies Checked 0 host dependencies Checked 5 timeperiods Checking global event handlers... Checking obsessive compulsive processor commands... Checking misc settings... Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check [root@nagios01 nagios-plugins-2.1.2]#

    Start nagios service and enable it on Runlevel 3 and 5.

    [root@nagios01 nagios-plugins-2.1.2]# chkconfig --level 35 nagios on [root@nagios01 nagios-plugins-2.1.2]# service nagios start

    Disable SELinux.

    [root@nagios01 nagios-plugins-2.1.2]# setenforce 0 [root@nagios01 nagios-plugins-2.1.2]# sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config && cat /etc/selinux/config

    Allow HTTP Port in Linux firewall using iptables.

    [root@nagios01 nagios-plugins-2.1.2]# iptables -I INPUT 5 -p tcp --dport 80 -m state --state NEW,ESTABLISHED -j ACCEPT [root@nagios01 nagios-plugins-2.1.2]# service iptables save

    Now open Nagios in browser, and user the nagiosadmin to login.

    Basic HTTP Authentication Login

    Nagios Core Server DashboardNagios Core Server Current Network Status

    Nagios Core Server Tactical Monitoring OverviewNagios Core Server Service Information

    Nagios Core 4.2 Server has been installed successfuly on our CentOS 6.7 server.

    2 comments:

    1. Ahmer, This post will definitely help a lot. Additionally we can use Nagstamon as the desktop application or client tool to keep monitoring the nagios.

      https://exchange.nagios.org/directory/Addons/Frontends-(GUIs-and-CLIs)/Windows-Interfaces/Nagstamon/details

      And check_oracle_health plugin can be used to monitor the database.
      https://exchange.nagios.org/directory/Plugins/Databases/Oracle/check_oracle_health/details


      Dilli Raj Maharjan

      ReplyDelete