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.
[[email protected] ~]# 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
[[email protected] ~]# useradd nagios [[email protected] ~]# groupadd nagcmd [[email protected] ~]# usermod -a -G nagcmd nagios [[email protected] ~]# usermod -a -G nagcmd apache
II/Download and Install Nagios
Let’s download nagios and extract it:
[[email protected] ~]# cd /tmp [[email protected] tmp]# wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.1.1.tar.gz [[email protected] tmp]# tar zxf nagios-4.1.1.tar.gz [[email protected] tmp]# tar zxf nagios-plugins-2.1.1.tar.gz [[email protected] tmp]# cd nagios-4.1.1
Now,let’s start compiling Nagios:
[[email protected] nagios-4.1.1]# ./configure --with-nagios-group=nagios --with-command-group=nagcmd [[email protected] nagios-4.1.1]# make all [[email protected] nagios-4.1.1]# make install [[email protected] nagios-4.1.1]# make install-init [[email protected] nagios-4.1.1]# make install-config [[email protected] nagios-4.1.1]# make install-commandmode [[email protected] 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.
[[email protected] ~]# 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:
[[email protected] ~]# cd /tmp [[email protected] ~]# wget http://www.nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz [[email protected] ~]# tar xzf nagios-plugins-2.1.1.tar.gz [[email protected] ~]# cd nagios-plugins-2.1.1
Let’s compile:
[[email protected] nagios-plugins-2.1.1]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl [[email protected] nagios-plugins-2.1.1]# make all [[email protected] nagios-plugins-2.1.1]# make install
III/Download and Install NRPE
[[email protected] ~]# cd /tmp [[email protected] ~]# wget http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz [[email protected] ~]# tar xzf nrpe-2.15.tar.gz [[email protected] ~]# cd nrpe-2.15/
Let’s install the nrpe addon and plugins:
[[email protected] nrpe-2.15]# [[email protected] nrpe-2.15]# ./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios [[email protected] nrpe-2.15]# make all [[email protected] 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:
[[email protected] ~]# vim /usr/local/nagios/etc/nagios.cfg
And uncomment this line
cfg_dir=/usr/local/nagios/etc/servers
Now let’s create the directory:
[[email protected] ~]# mkdir /usr/local/nagios/etc/servers [[email protected] ~]# 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:
[[email protected] ~]# 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
[r[email protected] ~]# 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 ?