This post will help you to know How to install Nagios Core server 4.4.3 on RHEL 6/7 & CentOS 6/7.
Nagios is a powerful monitoring tool. It will help to monitor a infrastructure.
It will monitor applications, service and entire infrastructure.
Required Packages:
- httpd
- php
- php-cli
- gcc
- unzip
- wget
- glibc
- glibc-common
- gd
- gd-devel
- net-snmp
[root@nagiosrv ~]yum install httpd php php-cli gcc unzip wget glibc glibc-common gd gd-devel net-snmp
As we have installed httpd and this will be useful when we access the Nagios core to manage through web console.
[root@nagiosrv yumrepo]# systemctl start httpd
Now create Nagios user account using below command:
[root@nagiosrv yumrepo]# useradd Nagios
[root@nagiosrv yumrepo]# passwd nagios
Changing password for user nagios.
New password:
BAD PASSWORD: The password contains the user name in some form
Retype new password:
passwd: all authentication tokens updated successfully.
Now we need to create a group “nagcmd” to setup Nagios and then add the users “nagios” & “apache” to be a part of group: nagcmd
[root@nagiosrv yumrepo]# groupadd nagcmd
[root@nagiosrv yumrepo]# usermod -a -G nagcmd nagios
[root@nagiosrv yumrepo]# usermod -a -G nagcmd apache
Ñow its time to start Nagios Core server installation
Since Nagios third party tool, we need to download first for installation using below commands:
[root@nagiosrv ~]# cd /opt
[root@nagiosrv opt]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.3.tar.gz
[root@nagiosrv opt]# tar -xvf nagios-4.4.3.tar.gz
[root@nagiosrv nagios-4.4.3]# ./configure --with-command-group=nagcmd
[root@nagiosrv nagios-4.4.3]# make all
[root@nagiosrv nagios-4.4.3]# make install
[root@nagiosrv nagios-4.4.3]# make install-init
[root@nagiosrv nagios-4.4.3]# make install-daemoninit
[root@nagiosrv nagios-4.4.3]# make install-commandmode
[root@nagiosrv nagios-4.4.3]# make install-config
[root@nagiosrv nagios-4.4.3]# make install-exfoliation
Now configure Apache for Nagios installation using below command:
[root@nagiosrv nagios-4.4.3]# make install-webconf
Will configure Apache authentication for nagiosadmin which is default user. Don’t change this username. If you are changing then need to do more changes in configuration file.
[root@nagiosrv nagios-4.4.3]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Now restart the apache
[root@nagiosrv nagios-4.4.3]# systemctl restart httpd
As a next step need to install Nagios plugins, once installed Nagios core using below commands:
[root@nagiosrv nagios-4.4.3]# cd /opt
[root@nagiosrv opt]# wget http://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
[root@nagiosrv opt]# tar -xvf nagios-plugins-2.2.1.tar.gz
[root@nagiosrv opt]# cd nagios-plugins-2.2.1
Now install and compile the plugins using below command:
[root@nagiosrv nagios-plugins-2.2.1]# ./configure --with-nagios-user=nagios --with-nagios-group=Nagios
[root@nagiosrv nagios-plugins-2.2.1]# make
[root@nagiosrv nagios-plugins-2.2.1]# make install
We installed Nagios core and plugins. So, now will check and verify the configuration using below command:
[root@nagiosrv nagios-plugins-2.2.1]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
The output should give 0 Errors and 0 Warnings. If you get the same, then will start the Nagios like below
[root@nagiosrv nagios-plugins-2.2.1]# systemctl start nagios
Check SELinux mode using below command:
[root@nagiosrv ~]getenforce
Enforcing
If SELinux is in Enforcing mode, Than change it to Permissive mode or disable it like below
[root@nagiosrv ~]# setenforce 0
Now make sure to enable web server permanently in firewall using below command:
[root@nagiosrv ~]# firewall-cmd --permanent --add-service=http
Execute below command to make affect in firewall changes which we did using our previous command
[root@nagiosrv ~]# firewall-cmd –reload
Finally we have done everything and now will check whether the web console working on not
Enter url like below in your web browser and replace the IP_ADDR with your server ip
It will ask for the username and password. Remember that we already created a user name “nagiosadmin”. We can use that to login the console.
Enter the nagiosadmin credentials and the web console looks like below
From the left side pan click on “Hosts” and it will show list of hosts which is added for monitoring.
Since, we doesn’t added any host, it will show only localhost, which is Nagios server like below
Finally we installed and configured Nagios server. Thanks for readin