• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Monitor Memory, CPU and Disk on Linux using NRPE and Nagios

Written by Rahul, Updated on January 11, 2018

Nagios is the most popular monitoring server for the infrastructure monitoring. In the series of Nagios monitoring tutorials, this tutorial will help you to monitor Memory, CPU, and Disk on a remote Linux system using Nagios and NRPE. I assume you have a running Nagios server on your network.

Prerequisites:

You have installed NRPE client on your Linux system. Use the following commands to install NRPE on your system or visit our tutorials for the NRPE installation on Debian based systems and Redhat based systems.

Debian systems:

apt-get install nagios-nrpe-server

Redhat systems:

sudo yum install nrpe nagios-plugins

NRPE default configuration file is /etc/nagios/nrpe.cfg. You need to edit this file for making changes as per next instructions.

Monitor CPU Load

A Nagios plugin check_load is available to check current CPU load on the system. Edit NRPE configuration file and check for the following entry. This should be default available there. You don’t need to make any changes.

1
command[check_load]=/usr/lib/nagios/plugins/check_load -w 15,10,5 -c 30,25,20

Let’s verify configuration by running check_nrpe command from the Nagios server

As per the above screenshot, Nagios server sent NRPE requests to defined host (192.168.1.15) to execute command check_load and send results back. The requests go to remote host and NRPE server checks for the command defined as check_load and execute it.

Monitor Memory Uses

A Nagios plugin is available to monitor memory uses on Linux system. You can download the check_mem.pl and configure with NRPE daemon. Download check_mem.pl using the following command and copy it to Nagios plugins directory. On CentOS/RHEL 64-bit systems this local will be /usr/lib64/nagios/plugins.

cd /usr/lib/nagios/plugins/
wget https://raw.githubusercontent.com/justintime/nagios-plugins/master/check_mem/check_mem.pl
chmod +x check_mem.pl

Edit NRPE configuration file and add a command to check memory uses like below. This will not calculate the swap memory in results.

1
command[check_mem]=/usr/lib/nagios/plugins/check_mem.pl -f -w 20 -c 10

      -w 20 – Send a warning message if free memory is less 20% of the total memory.
      -c 10 – Send a critical message if free memory is less 10% of the total memory.

Let’s verify configuration by running check_nrpe command from the Nagios server

Monitor Disk Uses

A Nagios plugin check_disk is available to check disk status. Edit NRPE configuration file and add the following entry to check disk /dev/sda1.

1
command[check_sda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1

      -w 20% – Sent a warning message if the free disk is less than 20% of the total disk.
      -c 10% – Sent a critical message if the free disk is less than 10% of the total disk.
      -p /dev/sda1 – Defines disk to be checked.

You can also define the mount point instead of disk name to monitor. For example, monitoring the root (/) disk or other mounts like (/mnt)

1
2
command[check_root_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /
command[check_mnt_disk]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /mnt

Let’s verify configuration by running check_nrpe command from the Nagios server

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

13 Comments

  1. Avatar jhonatan Reply
    June 6, 2020 at 5:37 pm

    Hi , when i create the services on Nagios web servers says: (No output returned from plugin)

  2. Avatar Vkodanam Reply
    November 19, 2019 at 2:22 pm

    Should the plugin be on the remote server or on the Nagios server?

    • Rahul Rahul Reply
      November 20, 2019 at 4:28 am

      NRPE and plugins needs to install on remote server.

  3. Avatar David Reply
    July 11, 2019 at 10:11 pm

    I cant use check_nrpe, i cant find it on my plugins

    • Avatar mahtab_alam Reply
      October 1, 2019 at 2:36 pm

      I can fix that

  4. Avatar Ahmad Lukman Hakim Reply
    May 8, 2019 at 2:41 am

    NRPE: Command ‘check_mem’ not defined

    • Avatar mahtab_alam Reply
      October 1, 2019 at 2:37 pm

      download check_mem.pl from nagios plugin website

      https://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_mem/details

  5. Avatar Narendra Kumar Reply
    April 15, 2019 at 10:25 am

    what system load is different than cpu load.

  6. Avatar a yadav Reply
    July 27, 2018 at 6:14 am

    Hi Rahul, i have successfully installed the nagios server. but i am not able to add hosts in nagios monitoring tool. please help me.

  7. Avatar Lino Vieira Reply
    April 4, 2018 at 2:22 pm

    Hello,

    I’m having trouble adding the rule to monitor the memory usage on a linux machine. On my Nagios machine the error it’s “NRPE: Command ‘check_mem.pl’ not defined”. Can you help me, please?

    • Rahul Rahul K. Reply
      April 4, 2018 at 2:32 pm

      Use check_mem as a command with NRPE.

      • Avatar Lino Vieira Reply
        April 5, 2018 at 2:10 pm

        Ok, but the script will still be called check_mem.pl, right? One more note, this script works on ubuntu 16.04 machines?

    • Avatar Vkodanam Reply
      November 20, 2019 at 9:22 pm

      You might have to restart the NRPE daemon after you make the change on the nrpe.cfg. Once you restart the daemon or service, NRPE should figure the changes in the cfg.

Leave a Reply Cancel reply

Popular Posts

  • How To Install Python 3.9 on Ubuntu 20.04 5
  • How To Install Python 3.9 on Ubuntu 18.04 0
  • How to Use AppImage on Linux (Beginner Guide) 2
  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy