HomeInstallationHow to Monitor a VPS Using Nagios

How to Monitor a VPS Using Nagios

Nagios Monitoring

As a server administrator, constantly checking the status of each server manually can be time-consuming and overwhelming. Monitoring individual commands and server health can quickly become a headache, especially in a large infrastructure. Thankfully, Nagios simplifies this task by providing a centralized monitoring solution. It continuously monitors the health of servers and notifies you of any issues. Business professionals, IT managers, and network engineers also struggle with maintaining the health and performance of their systems. 

Nagios is an ideal solution for all these professionals. It offers comprehensive monitoring capabilities, proactive alerting, and detailed reporting, making it easier to maintain optimal performance and uptime across diverse IT environments. By configuring Nagios to monitor remote servers, such as a Virtual Private Server (VPS), you can ensure that your systems are running smoothly without the need for constant manual checks. This guide will walk you through the steps to set up Nagios to monitor a remote VPS, streamlining your monitoring tasks and providing peace of mind. 

Prerequisites

  • A Nagios server already set up and running.
  • Root or sudo access to both the Nagios server and the remote VPS.
  • The remote VPS should be running a Linux-based operating system.

Configure remote server

1: Update the Package Manager

Ensure your system is up-to-date by running.

yum update

2: Install Required Packages

Install the NRPE (Nagios Remote Plugin Executor) and Nagios plugins packages:

yum install nrpe nagios-plugins-all

3: Configure NRPE

Edit the NRPE configuration file

vi /etc/nagios/nrpe.cfg
Set Allowed Hosts:

Add your Nagios server’s IP address to the allowed_hosts directive:

allowed_hosts=127.0.0.1,::1,<Nagios_Server_IP>
Define Commands:

Add command definitions for checks you want NRPE to execute:

command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_load]=/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
command[check_procs]=/usr/lib64/nagios/plugins/check_procs -w 150 -c 200
command[check_users]=/usr/lib64/nagios/plugins/check_users -w 5 -c 10

Adjust paths and thresholds as needed for your environment.

Configure Nagios Server

On your Nagios server, configure it to monitor the remote VPS using the NRPE plugin.

  1. Edit the Nagios services configuration file
cd /usr/local/nagios/etc/objects
vi server.conf
define host {
    use                     linux-server
    host_name               remote-vps
    alias                   Remote VPS
    address                 *********
    max_check_attempts      5
    check_period            24x7
    notification_interval   30
    notification_period     24x7
}

define service {
    use                     generic-service
    host_name               remote-vps
    service_description     Disk Usage
    check_command           check_nrpe!check_disk
}

define service {
    use                     generic-service
    host_name               remote-vps
    service_description     Load
    check_command           check_nrpe!check_load
}

define service {
    use                     generic-service
    host_name               remote-vps
    service_description     Processes
    check_command           check_nrpe!check_procs
}

define service {
    use                     generic-service
    host_name               remote-vps
    service_description     Users
    check_command           check_nrpe!check_users
}

Note: Add the above configuration, replacing <*********> with the appropriate IP address(Remote server):

2. Reload Nagios Configuration:

After making changes to the configuration, reload the Nagios service to apply them:

systemctl reload nagios

Verify Configuration

Test NRPE Locally on the Remote VPS:

  1. Ensure the NRPE commands work locally:
/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /
/usr/lib64/nagios/plugins/check_load -w 15,10,5 -c 30,25,20
verify NRPE

Access the Nagios Web Interface

Open a web browser and navigate to the Nagios web interface. The URL format will depend on your server’s IP address or hostname.

http://<server IP>/nagios
Nagios web interface

Conclusion

By following these steps, you can access the Nagios web interface, providing you with a powerful tool to monitor and manage your network infrastructure. The web interface offers a comprehensive overview of the status of your hosts and services, enabling you to quickly identify and address any issues. This streamlined monitoring process helps maintain optimal performance and reliability across your IT environment, reducing the burden on server administrators and other IT professionals.

Scroll to Top