Page 1 of 1

Need help on how to pass arguments for check_memory

Posted: Thu Sep 26, 2019 1:12 pm
by nagios102
Hello,

I'm trying to configure check_memory for a Windows server (nsclient++). It works fine on the command line
./check_nrpe -H <xxxx> -c check_memory -a "warn=used>95%" "crit=used>98%"

but it does not work as a define command and service. I've tried using escape character and also putting the arguments in double quotes but it's not working. It works fine as default (without any arguments). I've also tried to passing the arguments from define service but same issue. I think it has something to do with the = sign. When editing the commands.cfg file, everything after the = sign (=used>95% crit=used>98%") is red. I need help on how to pass arguments for check_memory. Thanks.

define service{
host_name xxxxxxxxxxxxx
...
check_command check_nrpe!check_memory
}

Working: no arguments
define command{
command_name check_memory
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_memory
}

Not working: with arguments. (looks like it skips everything after -a. I've tried -a type=physical but it doesn't work either)
define command{
command_name check_memory
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_memory -a "warn=used>95% crit=used>98%"
}

Re: Need help on how to pass arguments for check_memory

Posted: Thu Sep 26, 2019 2:38 pm
by mbellerue
Does anything show up in the message field when you have the service check configured? Usually this field shows whatever the output of the command was.

Re: Need help on how to pass arguments for check_memory

Posted: Fri Sep 27, 2019 8:45 am
by nagios102
I don't have the Nagios config tool (GUI). Can you recommend which one to use?

I can only edit config file manually and the Status on the web interface is showing "OK: committed = 15.108GB, physical = 10.791GB". The problem with the default setting is that warning is 80% or above and 90% for critical. However the server admin wants to have 90% for warning and 95% for critical so I've to add argument to filter the higher % alert. It seems it does not process anything after -a, even though the command line works fine with -a.

Re: Need help on how to pass arguments for check_memory

Posted: Fri Sep 27, 2019 12:01 pm
by mbellerue
Yes, the Status Information field in the web interface usually shows the output of the command. Does it show anything when the command isn't working?

Re: Need help on how to pass arguments for check_memory

Posted: Fri Sep 27, 2019 1:55 pm
by nagios102
The status is still showing the output, for example OK: committed = 15.108GB, physical = 10.791GB" or WARNING: committed ....

command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_memory -a "warn=used>90%" "crit=used>95%"

The check_memory is working fine. Right now, it seems to ignore everything after -a and still sends out Warning alert if the memory used is above 80% (the default).

I just need help on how to format the custom warning/critical part in red: -a "warn=used>90%" "crit=used>95%" so that Nagios will send out Warning alert if and only if memory usage is 90% or above. Thanks

Re: Need help on how to pass arguments for check_memory

Posted: Fri Sep 27, 2019 2:32 pm
by mbellerue
Ah, yes I'm sorry I misunderstood. I thought the command was just plain not working when run as a service check.

Check the nsclient.ini file on your Windows server, can you verify that you have the following settings,

Code: Select all

allow arguments = 1
allow nasty characters = true

Re: Need help on how to pass arguments for check_memory

Posted: Sat Sep 28, 2019 6:30 am
by nagios102
Yes, verified I've the following settings in my nsclient.ini:

Code: Select all

allow arguments = 1
allow nasty characters = true
As mentioned, the command works correctly on CLI but not as service check.
./check_nrpe -H <xxxxxx> -c check_memory -a "warn=used>90%" "crit=used>95%"
OK: committed = 15.592GB, physical = 11.145GB|'committed'=15.59186GB;18.44955;19.47452;0;20.4995 'committed %'=76%;90;95;0;100 'physical'=11.14541GB;14.39955;15.19952;0;15.9995 'physical %'=70%;90;95;0;100

Re: Need help on how to pass arguments for check_memory

Posted: Sat Sep 28, 2019 2:04 pm
by nagios102
Got it working finally! Thanks. :)

Re: Need help on how to pass arguments for check_memory

Posted: Mon Sep 30, 2019 6:48 am
by scottwilkerson
nagios102 wrote:Got it working finally! Thanks. :)
Great!

Locking