Page 2 of 2

Re: How Does NRPE Calculate Memory

Posted: Wed May 29, 2019 6:31 am
by mkeey
Our Linux Admin did some digging and found this article...

https://support.nagios.com/kb/article.php?id=171

NRPE - Linux Cached Memory Not Added to Free Memory Article Number: 171 | Rating: Unrated | Last Updated by tlea on Tue, Feb 9, 2016 at 9:29 PM
-> EDIT ARTICLE <-
Problem Description
In older versions of the Linux NRPE Agent, the memory plugin custom_check_mem did not take into account cached memory as part of the free memory and may create false warning or critical alerts, even though you are NOT low on memory.

Resolving The Problem
In order to fix this, we have updated the custom_check_mem plugin, part of our Linux agent install script by adding an optional flag [-n|--nocache]. Basically, cached memory is added to the free memory when you use the "-n" flag.
Usage:
custom_check_mem [-w|--warning]<percent free> [-c|--critical]<percent free> [-n|--nocache]

If you are downloading a new copy of our Linux agent, the updated custom_check_mem plugin will be included. If you already installed the Linux agent, you can just download the updated custom_check_mem from here. Copy the new script over the old custom_check_mem.
Next we need adjust any services to include the -n argument.
Go to Core Config Manager > Monitoring > Services Find the Memory Usage service and click it On the Common Settings tab modify the $ARG2$ field by adding a -n flag

For example, if you had:
-a '-w 20 -c 10'
Change it to:
-a '-w 20 -c 10 -n'



Question - How can I add this "-n" to all of our Linux memory monitors? We are currently at v5.5.5.

Re: How Does NRPE Calculate Memory

Posted: Wed May 29, 2019 6:55 am
by scottwilkerson
The -n was already in the config for the server you showed

Code: Select all

command[check_mem]=/usr/local/nagios/libexec/custom_check_mem -n $ARG1$
It can either be added there or to the service arguments like you mentioned
mkeey wrote:-a '-w 20 -c 10 -n'
but not both

Re: How Does NRPE Calculate Memory

Posted: Wed May 29, 2019 7:59 am
by mkeey
Not sure where you're seeing that. Look at the config I posed and memuse is coded...

define service {
host_name REMOTESERVERNAME
service_description Memory Usage
use xiwizard_nrpe_service
check_command check_nrpe!check_mem!-a '-w 10 -c 5'
max_check_attempts 24
check_interval 10
retry_interval 5
check_period xi_timeperiod_24x7
notification_interval 60
notification_period xi_timeperiod_24x7
notification_options n
notifications_enabled 0
contacts ENDUSERS
_xiwizard linux-server
register 1
}

I do not see the "-n". Am I looking in the wrong place?

Re: How Does NRPE Calculate Memory

Posted: Wed May 29, 2019 8:03 am
by mkeey
I checked in the XI and I don't see the "-n" in the command. See attached screen print.

Re: How Does NRPE Calculate Memory

Posted: Wed May 29, 2019 8:06 am
by mkeey
Tried it thru Config Manager...

Re: How Does NRPE Calculate Memory

Posted: Wed May 29, 2019 11:05 am
by scottwilkerson
mkeey wrote:Not sure where you're seeing that. Look at the config I posed and memuse is coded...
I'm seeing it in the common.cfg you posted here
https://support.nagios.com/forum/viewto ... 90#p282136
mkeey wrote:As requested...


[MYUSER@PROBLEMCHILD]:[/usr/local/nagios/etc/nrpe]# more common.cfg

### GENERIC SERVICES ###
command[check_init_service]=sudo /usr/local/nagios/libexec/check_init_service $A
RG1$
command[check_services]=/usr/local/nagios/libexec/check_services -p $ARG1$

### MISC SYSTEM METRICS ###
#command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_users]=/usr/local/nagios/libexec/check_users $ARG1$
command[check_load]=/usr/local/nagios/libexec/check_load $ARG1$
command[check_swap]=/usr/local/nagios/libexec/check_swap $ARG1$
command[check_cpu_stats]=/usr/local/nagios/libexec/check_cpu_stats.sh $ARG1$
command[check_mem]=/usr/local/nagios/libexec/custom_check_mem -n $ARG1$

### SYSTEM UPDATES ###
command[check_yum]=/usr/local/nagios/libexec/check_yum
command[check_apt]=/usr/local/nagios/libexec/check_apt

### DISK ###
command[check_disk]=/usr/local/nagios/libexec/check_disk $ARG1$
command[check_ide_smart]=/usr/local/nagios/libexec/check_ide_smart $ARG1$

### PROCESSES ###
command[check_all_procs]=/usr/local/nagios/libexec/custom_check_procs
command[check_procs]=/usr/local/nagios/libexec/check_procs $ARG1$

### OPEN FILES ###
command[check_open_files]=/usr/local/nagios/libexec/check_open_files.pl $ARG1$

### NETWORK CONNECTIONS ###
command[check_netstat]=/usr/local/nagios/libexec/check_netstat.pl -p $ARG1$ $ARG
2$

Re: How Does NRPE Calculate Memory

Posted: Thu May 30, 2019 1:05 pm
by mkeey
Talked with our Linux Admin and he seems happy... for now. Please close the case and thanks for your help.

Re: How Does NRPE Calculate Memory

Posted: Thu May 30, 2019 1:19 pm
by scottwilkerson
mkeey wrote:Talked with our Linux Admin and he seems happy... for now. Please close the case and thanks for your help.
great!

Locking thread