Bobcares

How to Add Ubuntu Host to Nagios?

by | Aug 26, 2022

At Bobcares our Server management support services can give you notes on how to add Add ubuntu host to Nagios in a few simple steps.

Adding a Ubuntu host to the Nagios server for monitoring using the NRPE plugin.

The Nagios Remote Plugin Executor (NRPE) agent permits remote execution of scripts hosted on the remote host. It enables the collection of metrics such as system load, disk use, and uptime, among others.

On the remote host, the NRPE Server (agent) and Plugins are installed. The agent will wait for the Nagios Core Server to send a check nrpe request. When the agent receives a check request, it will run a plugin on the remote host and submit the request back to the Nagios server.

Step 1: Install NRPE on Ubuntu

Nagios only discovers and monitors the server on which it is installed by default ( localhost ). To monitor a remote host, the NRPE packages must first be installed on the remote host. As an example, we will utilize Ubuntu 20.04 as our remote host on our local network to add an ubuntu host to Nagios.

So, first, log in to the remote computer and use the apt command to update the package index:

$ sudo apt update

Then, to install the Nagios plugins and NRPE agent, run the following command:

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

Once installed, use the following command to check the status of the NRPE agent:

$ sudo systemctl status nagios-nrpe-server
user@ubuntu-host:~$
use2ubuntu-host:~$ sudo systemct1 status nagios-nrpe-server
nagios-nrpe-server.service-Nagios Remote Plugin Executor
Loaded:loaded (/lib/systemd/system/nagios-nrpe-server.service; enabled; vendor predent: enabled)
Active: active (running) since Tsday 2022-08-25 14:15:46 UTC; 5min ago
Docs: http://WWW.nagios.org/documentation
Main PID: 581 (nrpe)
Tasks: 1 (limiy: 4713)
Memory: 1.0M
CGroup: /system.s;ice/nagios-nrpe-server.service
581 /usr/sbin/nrpe -c /etc/nagios/nrpe.cfg -f

The above result confirms that the NRPE agent is operational.

Step 2: Configure the NRPE agent

Step 2 of adding ubuntu host to Nagios is to monitor the remote target, we must go one step further and modify the NRPE configuration file. So, open the /etc/nagios/nrpe.cfg configuration file.

$ sudo vim /etc/nagios/nrpe.cfg

Locate the server address parameter and set it to the Nagios host’s IP address. In this situation, the remote host’s private IP address is ‘10.128.15.202’.

SERVER ADDRESS
Address that nrpe should bind to in case there are more than one interface and you do not want nrpe to bind on all interfaces.
NOTE: This option is ignored if NRPE is running under either ineta or xineta
server_address=0.128.15.202

Locate the allowed host’s argument, which is set to 127.0.0.1,0.0.0.0 by default. Change the second IP (0.0.0.0) to your Nagios server’s IP address. Our Nagios server’s private IP address is ‘10.128.15.204’.

Note: The daemon only does rudimentary checking of the client's IP
address. I would highly recommend adding entries in your /etc/hosts.allow file to allow only the specified host to connect to the port you are running this daemon on.
NOTE: This option is ignored if NRPE is running under either inetd or xinetd allowed_hosts=27.0.0.110.128.15.20

Save the modifications and then close the configuration file. Make sure to restart the NRPE agent daemon for the changes to take effect.

$ sudo systemctl restart nagios-nrpe-server

Run the following command on the remote host to determine the NRPE version:

$ sudo /usr/sbin/nrpe -V /etc/nagios/nrpe.cfg -f
Output:
NRPE - Nagios Remote Plugin Executor
Version: 4.0.0

The check nrpe script, which is provided on the Nagios core server, can be used to validate the connection from the Nagios server to the remote. To validate the connection, run the check nrpe script included in the plugins directory, and type:

$ sudo check_nrpe -H remote-host-ip-address

Step 3: Add host to Nagios server

We have completed the host-side setups for adding ubuntu host to Nagios. The only thing left is to configure the host on the Nagios monitoring server. But first, let’s make some changes to the Nagios configuration file.

$ sudo vim /usr/local/nagios/etc/nagios.cfg

Uncomment the line below to specify the path of the Nagios host configuration directory.

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

We can also tell Nagios to process all config files (with a .cfg # extension) in a particular directory by using the cfg_dir # directive as shown below:

cfg_dir= usr/local/nagios/etc/servers
#cfg dir=/usr/local/nagios/etc/printers
#cfg_dir=/usr/local/nagios/etc/switches
#cfg_dir=/usr/local/nagios/etc/routers

Then create the directory in the path that WE specified.

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

And, in this case, generate the host’s configuration file, host.cfg.

$ sudo vim /usr/local/nagios/etc/servers/host.cfg

Copy and paste the following content. Replace the values for ‘use,’ ‘host name,’ ‘alias,’ and ‘address’ with those of the remote host to add ubuntu host to Nagios.

define host {
use linux-server
host_name ubuntu-host
alias Apache server
address 10.128.15.202
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}

Finally, restart the Nagios service to apply the changes.

$ sudo systemctl restart nagios

Step 4: Configure the UFW firewall

By default, the Nagios NRPE agent listens on port 5666. If we have the UFW firewall enabled, we must open this port on both the Nagios host and the server. To accomplish this, execute the following commands.

$ sudo ufw allow 5666/tcp
$ sudo ufw reload

Then confirm that the port has been permitted.

$ sudo ufw status

add ubuntu host to nagios

Finally, use the command: to confirm that all of the configurations are correct and this is the final step in adding the ubuntu host to nagios.

$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

So, go to the Nagios dashboard and click on the ‘Hosts’ link in the left sidebar to see that the host has been automatically recognized and added to the Nagios server for monitoring.

[Need assistance with similar queries? We are here to help]

Conclusion

To conclude we have now learned to add an Ubuntu host to Nagios with the support of our Server management support services.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF