+5 votes
78 views
Install Nagios on Ubuntu

in Linux/Unix by (552k points)
reopened | 78 views

1 Answer

+3 votes
Best answer

How to install Nagios on Ubuntu

Ubuntu operating systems are characterized by their versatility to install numerous applications and configurations that allow the system to be more scalable and thus have the appropriate tools for comprehensive administration and one of the apps that will help us manage all this is Nagios. Nagios has been created as a tool with which one has access to the IT infrastructure to detect and repair problems that may jeopardize the integrity, availability and stability of both the system and everything that exists in them..

 

Nagios Features
Within the characteristics of Nagios we find:

 

  • Rapid detection of changes in the infrastructure.
  • Generation of alerts that can be sent directly to the administrator using email or SMS.
  • Centralized view of the managed IT infrastructure using the web interface.
  • It allows you to monitor applications, services, operating systems, network protocols, system metrics and infrastructure components from a single place.
  • Allows the use of scripting APIs to manage applications, services, and systems.
  • It has event handlers that create an automatic restart of failed applications and services.
  • Create availability reports to validate SLA compliance.
  • We will have access to historical reports to review the record of alerts, notifications, interruptions and more.

 

 

 

TechnoWikis will explain in detail how we can install Nagios in Ubuntu and thus have a comprehensive utility for monitoring hundreds of events.

 

 

To stay up to date, remember to subscribe to our YouTube channel!
SUBSCRIBE ON YOUTUBE

 

 

How to install Nagios on Ubuntu

 

Step 1

First of all we open the Ubuntu terminal and update the system:
 sudo apt update 
image

 

Step 2

Now we install the necessary dependencies:
 sudo apt install autoconf bc gawk dc build-essential gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev libmcrypt-dev make libssl-dev snmp libnet-snmp-perl gettext 
image

 

Step 3

By pressing Enter we must confirm the process by entering the letter S:

 

image

 

Step 4

We hope that the process of downloading and installing these dependencies will proceed:

 

image

 

step 5

At the end we will see the following:

 

 

image

 

step 6

We try to download the latest version of Nagios:
 sudo wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.6.tar.gz 
step 7

In case of error, try to execute the following:
 sudo wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz 
image

 

step 8

If the error persists we open the browser and paste the URL:
 https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz 
step 9

The download will start automatically:

 

 

image

 

step 10

Once downloaded we access the Downloads folder and we can list the content with "ls":

 

image

 

step 11

We extract the content of the file downloaded from Nagios:
 sudo tar -xf nagios-4.4.6.tar.gz 
image

 

step 12

We access the created folder:
 cd nagios-(version) 
step 13

With "ls" we list its content:

 

 

image

 

step 14

We compile Nagios by running:
 sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled 
image

 

step 15

We hope this process is completed:

 

image

 

step 16

We execute the following command to compile the Nagios program:
 sudo make all 
image

 

step 17

Press Enter to start the process:

 

image

 

step 18

At the end of this process we will see the following:

 

image

 

step 19

Install the user group necessary to access the platform:
 sudo make install-groups-users 
image

 

step 20

We grant the required permissions:
 sudo usermod -a -G nagios www-data 
image

 

step 21

We install the Nagios binaries with the command:
 sudo make install 
image

 

step 22

We install the required scripts, first the startup daemon:
 sudo make install-daemoninit 
image

 

Step 23

Now the command mode:
 sudo make install-commandmode 
image

 

step 24

We execute the script to perform the configuration:
 sudo make install-config 
image

 

step 25

We install the Apache configuration for Nagios:
 sudo make install-webconf 
image

 

step 26

Now we activate the CGI module::
 sudo a2enmod rewrite cgi 
image
step 27

We restart Apache with the command:
 sudo systemctl restart apache2 
image

 

Step 28

We create the Apache user for Nagios:
 sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 
We assign the desired password and we must confirm it:

 

 

image

 

Step 29

We add Apache to the Ubuntu Firewall:
 sudo ufw allow apache 
image

 

step 30

We enable the Firewall at system startup:
 sudo ufw enable 
step 31

We reload the Firewall changes:
 sudo ufw reload 
image

 

step 32

We validate the status of the Firewall:
 sudo ufw status 
image

 

Step 33

We install the Nagios plugins with the command:
 sudo apt install monitoring-plugins nagios-nrpe-plugin 
image

 

Step 34

We enter the letter S to confirm:

 

image

 

step 35

We wait for this process to finish:

 

image

 

Step 36

We access the Nagios directory and create a new directory:
 cd /usr/local/nagios/etc sudo mkdir -p /usr/local/nagios/etc/servers 
image

 

Step 37

We access the configuration file with some editor:
 sudo nanonagios.cfg 
Step 38

There we locate the cfg_dir section:

 

 

image

 

Step 39

We uncomment the line:
 cfg_dir=/usr/local/nagios/etc/servers 
image

 

step 40

We save the changes using the following key combination:

 

Ctrl + O

 

We exit the editor using:

 

Ctrl + X

 

 

Step 41

We access the file with an editor:
 sudo nanoresource.cfg 
We will see this:

 

 

 

image

 

step 42

We establish:
 $USER1$=/usr/lib/nagios/plugins 
Apply the changes.

 

 

image

 

Step 43

It is possible to add a management mail in the route. There we must use the value "email" and add the address.
 sudo nano objects/contacts.cfg 
image

 

Step 44

We assign the nrpe command in the path:
 sudo nano objects/commands.cfg 
step 45

We add the following at the end:
 define command{ command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } 
Apply the changes.

 

 

image

 

Step 46

NRPE (Nagios Remote Plugin Executor) is a module with which it is possible to perform active monitoring using an agent installed on the resources to be monitored. After this we start and enable the Nagios service:
 systemctl start nagios systemctl enable nagios 
image

 

Step 47

Check the status of Nagios:
 systemctl status nagios 
image

 

Step 48

We restart Apache:
 systemctl restart apache2 
image

 

Step 49

We open a browser, enter the following syntax:
 https://IP/nagios/ 
step 50

We enter the username and password assigned:

 

 

image

 

step 51

We will have access to the Nagios console in Ubuntu:

 

image

 

step 52

We explore the Nagios options in Ubuntu:

 

image

 

step 53

We can review the status of critical services:

 

 

image

 

step 54

We have an event or log viewer:

 

image

 

From this point it will be possible to add equipment or more services to be centrally monitored and managed with Nagios in Ubuntu, taking full advantage of each of its usage characteristics..

 


by (3.5m points)
edited

Related questions

+5 votes
1 answer
asked Apr 18, 2023 in Linux/Unix by backtothefuture (552k points) | 65 views
+3 votes
1 answer
asked Apr 12, 2023 in Linux/Unix by backtothefuture (552k points) | 69 views
+5 votes
1 answer
asked Nov 23, 2022 in Linux/Unix by backtothefuture (552k points) | 78 views
+5 votes
1 answer
asked Oct 26, 2023 in Linux/Unix by backtothefuture (552k points) | 88 views
+4 votes
1 answer
asked Jun 23, 2023 in Linux/Unix by backtothefuture (552k points) | 68 views
Sponsored articles cost $40 per post. You can contact us via Feedback

Most popular questions within the last 30 days

10,659 questions
10,791 answers
510 comments
3 users