Monitor Remote Server Memory Usage

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
ep7network
Posts: 51
Joined: Sun Dec 27, 2015 5:04 pm

Monitor Remote Server Memory Usage

Post by ep7network »

On my remote server, I'm running CentOS and I've installed "yum install nrpe nagios-plugins -all openssl".
My Nagios server is able to monitor CPU, SSH,Total Processes, and Logged in users on my remote server.
I would like to monitor memory on my remote server and visually see it on my Nagios web interface. Currently on my Nagios server, the memory service is displaying "status critical with NRPE: command 'check_mem' not defined."
On my remote server (client), I have configured NRPE to monitor memory usage. I used " wget https://raw.githubusercontent.com/justi ... eck_mem.pl" and was able to download and install it successfully. I say successfully because I can run ./check_mem -f -w 20 -c 10 and the output displays this "OK - 78.5% (3076688 kB) free.|TOTAL=3921616KB;;;; USED=844928KB;3137292;3529454;; FREE=3076688KB;;;; CACHES=713696KB;;;;"
As a result, the command is working on the remote client side. In addition, on the remote server side in /etc/nagios/nrpe.cfg I added this
"command[check_mem]=/usr/lib64/nagios/plugins/check_mem -f -w 20 -c 10"
What do I need to do on the Nagios server side recognize check_mem?
Also on the nagios server side in the /usr/local/nagios/etc/servers/client.cfg I have entered this
define service {
use generic-service
host_name NS1
service_description Memory
check_command check_nrpe!check_mem
}
When I run the command "/usr/local/nagios/libexec/check_nrpe -H 172.x.x.x -c check_mem
" from my Nagios server I get this error message "NRPE: Command 'check_mem' not defined"
tgrtjake
Posts: 20
Joined: Thu Sep 25, 2014 10:35 am

Re: Monitor Remote Server Memory Usage

Post by tgrtjake »

On your Nagios server you need to define check_mem in your commands.cfg.

Here's mine defined.

Code: Select all

# 'check_mem' command definition
define command{
        command_name    check_mem
        command_line    perl /usr/local/nagios/libexec/check_mem.pl -w $ARG1$ -c $ARG2$ -f
        }
Nagios Core 4.1.1 running on Ubuntu 14.04
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Monitor Remote Server Memory Usage

Post by hsmith »

I have to ask the obvious question: Did you restart npre/xinetd after you added the configuration changes to the nrpe.cfg file?
Former Nagios Employee.
me.
alyssa909
Posts: 3
Joined: Mon Dec 28, 2015 6:33 pm

Re: Monitor Remote Server Memory Usage

Post by alyssa909 »

tgrtjake wrote:On your Nagios server you need to define check_mem in your commands.cfg.

Here's mine defined.

Code: Select all

# 'check_mem' command definition
define command{
        command_name    check_mem
        command_line    perl /usr/local/nagios/libexec/check_mem.pl -w $ARG1$ -c $ARG2$ -f
        }
alyssa909
Posts: 3
Joined: Mon Dec 28, 2015 6:33 pm

Re: Monitor Remote Server Memory Usage

Post by alyssa909 »

tgrtjake wrote:On your Nagios server you need to define check_mem in your commands.cfg.

Here's mine defined.

Code: Select all

# 'check_mem' command definition
define command{
        command_name    check_mem
        command_line    perl /usr/local/nagios/libexec/check_mem.pl -w $ARG1$ -c $ARG2$ -f
        }
ep7network
Posts: 51
Joined: Sun Dec 27, 2015 5:04 pm

Re: Monitor Remote Server Memory Usage

Post by ep7network »

tgrtjake wrote:On your Nagios server you need to define check_mem in your commands.cfg.

Here's mine defined.

Code: Select all

# 'check_mem' command definition
define command{
        command_name    check_mem
        command_line    perl /usr/local/nagios/libexec/check_mem.pl -w $ARG1$ -c $ARG2$ -f
        }
On my nagios web interface I can finally see memory status OK. My question is how is it working if i didn't add the command you mention in my commands.cfg?
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Monitor Remote Server Memory Usage

Post by rkennedy »

What changes did you make?
Former Nagios Employee
ep7network
Posts: 51
Joined: Sun Dec 27, 2015 5:04 pm

Re: Monitor Remote Server Memory Usage

Post by ep7network »

rkennedy wrote:What changes did you make?
The only changes I did were
1)Install this "wget https://raw.githubusercontent.com/justi ... eck_mem.pl" on remote server.
2) Then I was able to successfully run this command from remote server "./check_mem -f -w 20 -c 10 ".
3) On remote server side I then entered this file "/etc/nagios/nrpe.cfg " and then typed this "command[check_mem]=/usr/lib64/nagios/plugins/check_mem -f -w 20 -c 10" (I think this solved the issue)
4) On the nagios server side, I entered the config file to the client that is being monitored and entered this
define service {
use generic-service
host_name NS1
service_description Memory
check_command check_nrpe!check_mem
}

And rebooted both servers and it started working!
My issue is I never typed anything in the commands.cfg from the server side! I
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Monitor Remote Server Memory Usage

Post by hsmith »

ep7network wrote:My question is how is it working if i didn't add the command you mention in my commands.cfg?
The script they were telling you to set up has nothing to do with NRPE. You wouldn't need that command definition to make it work via NRPE. To run a NRPE check, all of the configuration will need to be done on the server that is running NRPE. Adding the definition to nrpe.cfg in your case.

Rebooting the server would have restart the nrpe daemon, which in this case was all you needed to do to get it to know how to do the check_mem command.
Former Nagios Employee.
me.
ep7network
Posts: 51
Joined: Sun Dec 27, 2015 5:04 pm

Re: Monitor Remote Server Memory Usage

Post by ep7network »

hsmith wrote:
ep7network wrote:My question is how is it working if i didn't add the command you mention in my commands.cfg?
The script they were telling you to set up has nothing to do with NRPE. You wouldn't need that command definition to make it work via NRPE. To run a NRPE check, all of the configuration will need to be done on the server that is running NRPE. Adding the definition to nrpe.cfg in your case.

Rebooting the server would have restart the nrpe daemon, which in this case was all you needed to do to get it to know how to do the check_mem command.
Thank you guys very much. You guys provide outstanding nagios IT support.
Locked