Breaking News
Home / How To / How to install Nagios Monitoring Software on Ubuntu 18.04 LTS

How to install Nagios Monitoring Software on Ubuntu 18.04 LTS



Nagios is open source software for monitoring systems and networks. Nagios can monitor the activity of a host and its services and give a warning / warning if something bad happens on the server. Nagios can run on Linux operating systems, and we will use the Ubuntu 18.04 server.

In this tutorial we will show you step by step install Nagios 4.4.x on Ubuntu 1

8.04. We will install Nagios Core 4.4.x from the source, install nrpe and nagios plugins and then add host to monitor to the Nagios server.

Prerequisites

  • 2 Ubuntu 18.04 servers
    • Nagios server – host name: hakase-nagios with an IP: 10.5.5.11
    • Ubuntu client – host name: client01 with an IP: 10.5 .5.12
  • Root Privileges

What We Will Do:

  • Install Package Dependency
  • Install Nagios Core 4.4.5
  • Install Nagios Plugin and NRPE Plugin
  • Add Host to Monitor for Nagios Server [19659010] Test

Step 1 – Install package dependency

First, we will update the Ubuntu repository and install some package dependencies for the installation of Nagios.

Update the Ubuntu archive with the apt command below.

  sudo apt update 

After installing package dependencies for installation of Nagios.

  sudo apt install -y autoconf bc gawk dc build-essential gcc libc6 does wget unzip apache2 php libapache2-mod-php7.2 libgd-dev libmcrypt-dev does libssl-dev snmp libnet-snmp-perl gettext 

And you have installed packages given dependencies for Nagios server.

Step 2 – Install Nagios Core 4.4.5

In this step we will install the latest stable version Nagios Core 4.4.5. And we install it manually from the source.

Download Nagios Core 4.4.5

Go to your home directory and download Nagios Core source code.

  cd ~ / 
wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.5.tar.gzebrit19659018achteExtrahera Nagios package and go to the extracted Nagios directory.

  takes xzf nagios-4.4.5.tar.gz 
cd nagioscore-nagios-4.4.5 /

Compile and install Nagios

First compile Nagio's source code and define Apache virtual host configuration for Nagios.

  sudo ./configure --with-httpd-conf = / etc / apache2 / sites-enabled 
sudo make all

 Compile Nagios

Create Nagios users and group and add & # 39; www data & # 39; Apache users to & # 39; nagios & # 39; group.

  sudo make install-groups-users 
sudo usermod -a -G nagios www-data

 Install groups and users [19659015] Install Nagios binaries, service daemon scripts and command mode.

  sudo make install 
sudo make install daemoninit
sudo make install commandmode

After that, install the sample script configuration.

  sudo make install-config 

Then install the Apache configuration for Nagios and enable mod_rewrite and mode_cgi modules.

  sudo make install-webconf 
sudo a2enmod rewrite cgi

Now restart the Apache service.

  systemctl restart apache2 

And you have installed Nagios Core 4.4.5.

[19659016]   Installing Nagios Configuration

Creating Nagiosadmin Users

After installing Nagios Core, we add the basic authentication for access to the Nagios dashboard. And we will use the basic Apache authentication.

Create a new apache basic authentication for user "nagiosadmin".

  sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 

Enter your strong password.

 Set password for Nagios admin Ads

And you created a new user & # 39; nagiosadmin & # 39; for Nagios dashboard verification.

UFW Firewall Setting

For the firewall configuration, you must add the Apache service and Nagios server port to the UFW firewall.

Add Apache HTTP port and Nagio's port & # 39; & # 39; using the ufw command below.

  sudo ufw allow Apache 

Reload the UFW firewall now.

  sudo ufw reload 

And you have completed the Nagios Core installation on the Ubuntu 18.04 server.

 Configure UFW Firewall

Step 3 - Install Nagios Plugins and NRPE Plugin [19659015] After installing Nagios Core, we will install Nagios Plugins and NRPE Plugins.

By default, both Nagios and NRPE plugins are available on the Ubuntu repository. You can install these packages using the apt command below.

  sudo apt install nagios-plugins nagios-nrpe-plugin 

When the installation is complete, go to nagios installation directory "/ usr / local / nagios" and edit the configuration file "nagios.cfg".

  cd / usr / local / nagios / 
vim nagios.cfg

Uncheck the additional server configuration directory. Ads

  cfg_dir = / usr / local / nagios / etc / servers 

Save and close.

Now create a new directory "/ usr / local / nagios / etc / servers" that will be used to store the host monitor configuration.

  mkdir -p / usr / local / nagios / etc / servers 

Then go to the "/ usr / local / nagios / etc /" directory and edit the "resurces.cfg" configuration file.

  cd / usr / local / nagios / etc / 
vim resources.cfg

Change the default directory for Nagios plugins as below.

  $ USER1 $ = / usr / lib / nagios / plugins 

Save and close. [19659016] Then add na gio's admin contacts by editing the configuration objects "objects / contacts.cfg".

  vim objects / contacts.cfg 

Change your email address with your own.

  define contact {
......
email [email protected]
}

Save and close.

Then define the nrpe control command by editing the "objects / commands.cfg" configuration file.

  vim objects / commands.cfg 

Paste the following configuration to the end of the row.

  define command {
command_name check_nrpe
command_line $ USER1 $ / check_nrpe -H $ HOSTADDRESS $ -c $ ARG1 $
}

Save and close.

Now start the Nagios service and add it to the system boot.

  systemctl start nagios 
systemctl enable nagios

 Configure nagios, then restart it to apply changes

The Nagios service is running, check using the following command.

  systemctl status nagios 

Below is the result.

 Checking Nagios Status

Then we need to restart the Apache service to apply a new Nagios configuration.

  sy stemctl restart apache2 

Then open your browser and enter the server IP address after the URL path "nagios".

http://10.5.5.11/nagios/

Log in with the user "nagiosadmin" and enter your password.

 Nagios Login

And you get the Nagios Dashboard as below. Ads

Ads

 Nagio's dashboard

As a result, you have installed Nagios on the Ubuntu 18.04 server. And you can add hosts to the Nagios server.

Step 5 - Add Linux Host to Monitor

In this step we add the Ubuntu server with the host name "client01" and the IP address "10.5.5.12" to the Nagios server.

Installing the NRPE server on the Client01 server

Log in to the "client01" server with your ssh.

  ssh [email protected] 

After you log in, update the Ubuntu repository and install Nagios Plugins and NRPE Server.

  sudo apt update 
sudo apt install nagios-nrpe server nagios-plugins

Then go to NRPE installation directory "/ etc / nagios" and edit configuration file "nrpe.cfg".

  cd / etc / nagios / 
vim nrpe.cfg

Uncheck the line "server_address" and change the value with the IP address "client01".

  server_address = 10.5.5.12 

To the line "allow_hosts", add Nagios Server IP address "10.5.5.11".

  allow_hosts = 127.0.0.1, :: 1,10.5.5.11 

Save and close. [19659016] Then edit the configuration "nrpe_local.cfg".

  vim nrpe_local.cfg 

Change the IP address with the IP address "client01" and paste in the configuration in it.

  command [check_root] = / usr / lib / nagios / plugins / check_disk -w 20% -c 10% -p / 
command [check_ping] = / usr / lib / nagios / plugins / check_ping -H 10.5 .5.12 -w 100.0,20% -c 500.0,60% -p 5
command [check_ssh] = / usr / lib / nagios / plugins / check_ssh -4 10.5.5.12
command [check_http] = / usr / lib / nagios / plugins / check_http -I 10.5.5.12
command [check_apt] = / usr / lib / nagios / plugins / check_apt

Save and close.

Now restart the NRPE service and add it to the system boot.

  systemctl restart nagios-nrpe server 
systemctl enable nagios-nrpe server

And the Nagios NRPE server is running.

 Install NRPE

Ch Check the NRPE service with the following command.

  systemctl status nagios-nrpe server 

The NRPE service is running.

 NRPE Server is active and running

Next, return to the Nagios server and check the NRPE server "client01".

  / usr / lib / nagios / plugins / check_nrpe -H 10.5.5.12 
/ usr / lib / nagios / plugins / check_nrpe -H 10.5.5.12 -c check_ping

And you get the result as below.

 Check NRPE

And you have installed Nagios NRPE Server and Nagios Plugins on "client01" host. [19659140] Add host configuration to Nagios Server

Return to Nagios server terminal, go to directory "/ usr / local / nagios / etc" and create a new configuration "server / client01.cfg".

  cd / usr / local / nagios / etc 
vim servers / client01.cfg

Change the IP address and host name with your own and paste the configuration into it.

  # Ubuntu Host configuration file1 

define host {
use linux server
host_name client01
alias Ubuntu Host
address 10.5.5.12
register 1
} [19659139] define service {
host_name client01
service description PING
check_command check_nrpe! Check_ping
max_check_attempt 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
message_interval 2
message_9034] notification_period 24x7 1
}

define service {
host_name client01
service_design Check user
check_command check_nrpe! Check_users
max_check_attempt 2
check_interval 2
retry_interval 2
check_period 24x 7
check_freshness 1
contact_groups admins
message_interval 2
notification_period 24x24 register 1
}

define service {
host_name client01
service_description Check SSH
check_command check_nrpe! Check_ssh
max_check_attempt 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
message_interval 2
message_9034] message_period 24x7 1
}

define service {
host_name client01
service_description Check Root / Disk
check_command check_nrpe! Check_root
max_check_attempt 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
message_interval 2
message_903434_notification_period 24x7 1
}

define service {
host_name client01
service_descript Check APT update
check_command check_nrpe! Check_apt
max_check_attempt 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
message_interval 2
message_903434_notification_period 24x7 1
}

define service {
host_name client01
service_descript Check HTTP
] Check_command check_nrpe! Check_http
max_check_attempt 2
check_interval 2
retry_interval 2
check_period 24x7
check_freshness 1
contact_groups admins
message_interval 2
message_9034] message_period 24x7 1
}

Save and close.

Restart Nagios Server.

  systemctl restart nagios 

 Configure Nagios Client

Step 5 - Test

Return to your browser and wait a few minutes.

Click the " Hosts " menu and you will get "client01" added.

 Testing Nagios

Below is detailed monitoring of the "client01" server.

 Another Nagios Test

You have now added Host to monitor for Nagios Server.

And the installation on Nagios 4.4.5 on Ubuntu 18.04 Server has been successfully completed.

Reference


Source link