Page 1 of 2

Monitor Remote Server Memory Usage

Posted: Tue Dec 29, 2015 4:19 pm
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"

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 10:24 am
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
        }

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 10:28 am
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?

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 11:08 am
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
        }

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 11:13 am
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
        }

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 11:22 am
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?

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 11:28 am
by rkennedy
What changes did you make?

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 12:30 pm
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

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 12:37 pm
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.

Re: Monitor Remote Server Memory Usage

Posted: Wed Dec 30, 2015 12:47 pm
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.