Tue. Dec 10th, 2019

Host your Website

Read and learn

FatCow Web Hosting $1.00/mo* Trust your web hosting to the #1 web host provider, GoDaddy!

|How to Install| |and Upgrade| |Nagios-4.3.4 Server| |on Redhat & Centos 6 and 7|

3 min read

#theitguru# #|How to Install| |and Upgrade| |Nagios-4.3.4 Server| |on Redhat & Centos 6 and 7|#
Step 1: Install Required Dependencies
yum install -y httpd httpd-tools php gcc glibc glibc-common gd gd-devel make net-snmp

Step 2: Create Nagios User and Group
[[email protected]]# useradd nagios
[[email protected]]# groupadd nagcmd

Next, add both the nagios user and the apache user to the nagcmd group.
[[email protected]]# usermod -G nagcmd nagios
[[email protected]]# usermod -G nagcmd apache

Step 3: Download Nagios Core 4.3.4 and Nagios Plugin 2.2.1
Create a directory for your Nagios installation and all its future downloads.

[[email protected]]# mkdir /root/nagios
[[email protected]]# cd /root/nagios

Now download latest Nagios Core 4.3.4 and Nagios plugins 2.2.1 packages with wget command.
[[email protected] nagios~]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.3.4.tar.gz

[[email protected] nagios~]# wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz

Step 4: Extract Nagios Core and its Plugins
We need to extract the downloaded package with tar command as follows.

[[email protected] nagios~]# tar -xvf nagios-4.3.4.tar.gz
[[email protected] nagios~]# tar -xvf nagios-plugins-2.2.1.tar.gz

Configure Nagios Core

Now, first we will configure Nagios Core

[[email protected] nagios~]# cd nagios-4.3.4/
[[email protected] nagios-4.3.4 ]# ./configure –with-command-group=nagcmd

After configuring, we need to compile and install all the binaries with make all and make install command, it will install all the needed libraries in your machine and we can proceed further.

[[email protected] nagios-4.3.4 ]# make all
[[email protected] nagios-4.3.4 ]# make install

Following command will install the init scripts for Nagios.
[email protected] nagios-4.3.4 ]# make install-init

To make nagios work from command line we need to install command-mode.

[[email protected] nagios-4.3.4 ]# make install-commandmode

Next, install sample nagios files, please run following command.

[[email protected] nagios-4.3.4 ]# make install-config

Step 5: Customizing Nagios Configuration
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

Step 6: Install and Configure Web Interface for Nagios

We are done with all configuration in the backend, now we will configure Web Interface For Nagios with the following the command. The below command will Configure Web interface for Nagios and a web admin user will be created “nagiosadmin”.

[[email protected] nagios-4.3.4 ]# make install-webconf

In this step, we will be creating a password for “nagiosadmin”. After executing this command, please provide a password twice and keep it remember because this password will be used when your login in the Nagios Web interface.

[[email protected] nagios-4.3.4]# htpasswd -s -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Restart Apache to make the new settings take effect

[[email protected] ]# service httpd start [On RHEL/CentOS 6/5]

[[email protected] ]# systemctl start httpd.service [On RHEL/CentOS 7]

Step 7: Compile and Install Nagios Plugin
We have downloaded nagios plugins in /root/nagios, Go there and configure and install it as directed below.

[[email protected] nagios]# cd nagios-plugins-2.2.1/
[[email protected] nagios]# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
[[email protected] nagios]# make
[[email protected] nagios]# make install

Step 8: Verify Nagios Configuration Files
Now we are all done with Nagios configuration and its time to verify it and to do so please insert following command. If everything goes smooth it will show up similar to below output.

[[email protected] nagios]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Step 9: Add Nagios Services to System Startup
To make Nagios work across reboots, we need to add nagios and httpd with chkconfig and systemctlcommand.

[[email protected] ]# chkconfig –add nagios
[[email protected] ]# chkconfig –level 35 nagios on
[[email protected] ]# chkconfig –add httpd
[[email protected] ]# chkconfig –level 35 httpd on

[[email protected] ]# systemctl enable nagios
[[email protected] ]# systemctl enable httpd

Restart Nagios to make the new settings take effect

[[email protected] ]# service nagios restart [On RHEL/CentOS 6/5]
[[email protected] ]# systemctl restart nagios.service [On RHEL/CentOS 7

Step 10: Login to the Nagios Web Interface

Your nagios is ready to work, please open it in your browser with “http://Your-server-IP-address/nagios” or “http://FQDN/nagios” and Provide the username “nagiosadmin” and password.

Upgrade Nagios 3.x to Nagios 4.3.4

[[email protected] ]# service nagios stop
[[email protected] ]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.3.tar.gz
[[email protected] ]# tar -zxvf nagios-4.4.3.tar.gz
[[email protected] ]# cd nagios-4.4.3
[[email protected] ]# ./configure
[[email protected] ]# make all
[[email protected] ]# make install
[[email protected] ]# service nagios start

3 thoughts on “|How to Install| |and Upgrade| |Nagios-4.3.4 Server| |on Redhat & Centos 6 and 7|

Comments are closed.

Copyright © All rights reserved. | Newsphere by AF themes.