Today, i’m going to explain how to install nagios core 4.x on centos 7 /RHEL 7 and how to monitor linux & windows servers. Here, i will divide this tutorial in three parts:
1/ How to install nagios core 4.x on Centos 7 / RHEL 7.
2/ How to monitor a Centos 7 Linux remote host using nagios core.
3/ How to monitor a windows server remote host using nagios core.
What will do in this first tutorial:
1/ Install Prerequisites.
2/ Download and Install Nagios core 4.x.
3/ Download and Install Nagios Plugins.
4/ Download and Install NRPE.
5/ Configure Nagios.
I/Install Prerequisites
Because we are building Nagios Core from source, we must install a few development libraries that will allow us to complete the build and to set up the Nagios web interface.
[root@nagios ~]# yum install httpd php php-cli gcc glibc glibc-common gd gd-devel net-snmp openssl-devel wget unzip -y
Now, let’s create a user and group for Nagios to use
[root@nagios ~]# useradd nagios [root@nagios ~]# groupadd nagcmd [root@nagios ~]# usermod -a -G nagcmd nagios [root@nagios ~]# usermod -a -G nagcmd apache
II/Download and Install Nagios
Let’s download nagios and extract it:
[root@nagios ~]# cd /tmp [root@nagios tmp]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz [root@nagios tmp]# tar zxf nagios-4.1.1.tar.gz [root@nagios tmp]# tar zxf nagios-plugins-2.1.1.tar.gz [root@nagios tmp]# cd nagios-4.1.1
Now,let’s start compiling Nagios:
[root@nagios nagios-4.1.1]# ./configure --with-nagios-group=nagios --with-command-group=nagcmd [root@nagios nagios-4.1.1]# make all [root@nagios nagios-4.1.1]# make install [root@nagios nagios-4.1.1]# make install-init [root@nagios nagios-4.1.1]# make install-config [root@nagios nagios-4.1.1]# make install-commandmode [root@nagios nagios-4.1.1]# make install-webconf
After finishing,we need now to create a password for the nagiosadmin user that will be used for accessing to Nagios web GUI.
[root@nagios1 ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
By the way you can create another user but you should edit /usr/local/nagios/etc/cgi.cfg and change all the “nagiosadmin” references to the user that you have created.
III/Download and Install Nagios Plugins
Let’s download nagios Plugins and extract it:
[root@nagios ~]# cd /tmp [root@nagios ~]# wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz [root@nagios ~]# tar xzf nagios-plugins-2.1.1.tar.gz [root@nagios ~]# cd nagios-plugins-2.1.1
Let’s compile:
[root@nagios1 nagios-plugins-2.1.1]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl [root@nagios nagios-plugins-2.1.1]# make all [root@nagios nagios-plugins-2.1.1]# make install
III/Download and Install NRPE
[root@nagios ~]# cd /tmp [root@nagios ~]# wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz [root@nagios ~]# tar xzf nrpe-2.15.tar.gz [root@nagios ~]# cd nrpe-2.15/
Let’s install the nrpe addon and plugins:
[root@nagios nrpe-2.15]# [root@nagios nrpe-2.15]# ./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios [root@nagios nrpe-2.15]# make all [root@nagios nrpe-2.15]# make install-plugin
IV/Configure Nagios
– First, let’s create a directory called ” servers” where we will put the remote servers configuration files which will be monitored:
[root@nagios ~]# vim /usr/local/nagios/etc/nagios.cfg
And uncomment this line
cfg_dir=/usr/local/nagios/etc/servers
Now let’s create the directory:
[root@nagios ~]# mkdir /usr/local/nagios/etc/servers [root@nagios ~]# chown -R nagios.nagios /usr/local/nagios
– In order to use the check_nrpe plugin we need to create a command definition in the file commands.cfg:
[root@nagios ~]# vim /usr/local/nagios/etc/objects/commands.cfg
Add the following lines in the end of the file :
define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ }
Finally let’s enable and start nagios service
[root@nagios ~]# systemctl enable nagios && systemctl start nagios
That’s it for now, You can open your preferred browser and check if everything works properly http://you_nagios_ip_address/nagios and dont forget to start apache and open http service on your firewall.
We hope this tutorial was enough Helpful. If you need more information, or have any questions, just comment below and we will be glad to assist you!
2 comments
I’m more than happy to discover this great site.
I want to thank you for ones time for this wonderful read!!
I definitely savored every part of it and I have you book-marked to
check out new things in your site.
hello please i have a question, do i have to install nrpeand its plugin on the linux server and then i have to configure the rest onthe nagios server ?