Facebook Twitter Instagram
    TecAdmin
    • Home
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    You are at:Home»Monitoring Tools»Nagios»How to Monitor Memory, CPU and Disk on Linux using NRPE and Nagios

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

    By RahulOctober 4, 20223 Mins Read

    Nagios is the most popular monitoring server for 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.

    Advertisement

    Prerequisites

    You have installed the 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.

    • Ubuntu and Debian based systems:
      sudo apt install nagios-nrpe-server 
      
    • Redhat, CentOS systems:
      sudo dnf install nrpe nagios-plugins
      

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

    Monitor CPU Load

    A Nagios plugin check_load is available to check current CPU load on the system. Edit the 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 the configuration by running the check_nrpe command from the Nagios server

    As per the above screenshot, the Nagios server sent NRPE requests to the defined host (192.168.1.15) to execute command check_load and send results back. The requests go to the remote host and the 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 systems. You can download the check_mem.pl and configure with NRPE daemon. Download check_mem.pl using the following command and copy it to the 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.

    Now verify the configuration by running the check_nrpe command from the Nagios server

    Monitor Disk Uses

    A Nagios plugin check_disk is available to check disk status. Edit the 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 the 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 the configuration by running the check_nrpe command from the Nagios server

    cpu check disk check memory check nagios NRPE
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp

    Related Posts

    How to Install Nagios Client (NRPE) on Ubuntu 20.04

    Installing Nagios on Ubuntu

    How to Install Nagios Server on Ubuntu 20.04

    How To Install NRPE on LinuxMint 19/18

    View 13 Comments

    13 Comments

    1. jhonatan on June 6, 2020 5:37 pm

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

      Reply
    2. Vkodanam on November 19, 2019 2:22 pm

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

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

        NRPE and plugins needs to install on remote server.

        Reply
    3. David on July 11, 2019 10:11 pm

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

      Reply
      • mahtab_alam on October 1, 2019 2:36 pm

        I can fix that

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

      NRPE: Command ‘check_mem’ not defined

      Reply
      • mahtab_alam on October 1, 2019 2:37 pm

        download check_mem.pl from nagios plugin website

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

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

      what system load is different than cpu load.

      Reply
    6. a yadav on July 27, 2018 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.

      Reply
    7. Lino Vieira on April 4, 2018 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?

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

        Use check_mem as a command with NRPE.

        Reply
        • Lino Vieira on April 5, 2018 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?

          Reply
      • Vkodanam on November 20, 2019 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.

        Reply

    Leave A Reply Cancel Reply

    Advertisement
    Recent Posts
    • System.out.println() Method in Java: A Beginner’s Guide
    • Split Command in Linux With Examples (Split Large Files)
    • Test Your Internet Speed from the Linux Terminal
    • 11 Practical Example of cat Command in Linux
    • sleep Command in Linux with Examples
    Facebook Twitter Instagram Pinterest
    © 2023 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.