Page 1 of 1
Place an ARG inside another ARG in Service Check
Posted: Wed Feb 05, 2020 1:10 pm
by jvaira
Hello,
I am trying to create a service check using the check_nrpe command where $ARG3$ will be referenced within $ARG2$. The following is a specific example.
$ARG1$ CheckCounter
$ARG2$ -a "Counter:$ARG3$-Avg-Disk-Writes-Sec=\\Cluster CSVFS($ARG3$)\\Writes/sec" ShowAll MaxWarn=99999999 MaxCrit=99999999
$ARG3$ CSV10
If I test this out by using the run check command everything looks good, however when I look at status information under service status I see the following error. Failed to poll counter: -Avg-Disk-Writes-Sec PdhAddCounter failed: c0000bc0: Unable to parse the counter path. Check the format and syntax of the specified path.
Re: Place an ARG inside another ARG in Service Check
Posted: Wed Feb 05, 2020 2:55 pm
by benjaminsmith
Hello
@jvaira,
I would recommend defining this as a custom macro and then using this macro in your check commands.
check_arg.png
Nagios XI - Macros and Custom Object Variables
Re: Place an ARG inside another ARG in Service Check
Posted: Wed Feb 05, 2020 4:04 pm
by jvaira
Hello Ben,
I tried that and am now getting the following error instead Failed to poll counter: PdhCollectQueryData failed: : 800007d5: No data to return.
Re: Place an ARG inside another ARG in Service Check
Posted: Wed Feb 05, 2020 4:40 pm
by benjaminsmith
Hi,
Did you re-start Nagios Core after making changes to the resource.cfg file?
Re: Place an ARG inside another ARG in Service Check
Posted: Wed Feb 05, 2020 5:43 pm
by jvaira
Hello,
I set this up as a free variable within the service check and then applied config. Would modifying the resource.cfg file be different?
Re: Place an ARG inside another ARG in Service Check
Posted: Wed Feb 05, 2020 5:45 pm
by benjaminsmith
Hi,
Yeah, you'll want to use the user macros and add those to the
/usr/local/nagios/etc/resource.cfg file . Take a look at the following guide:
https://assets.nagios.com/downloads/nag ... Macros.pdf
Re: Place an ARG inside another ARG in Service Check
Posted: Wed Feb 05, 2020 6:50 pm
by jvaira
Hello Ben,
This did the trick, thank you. Just for my own understanding can you please explain why the free variables within the service do not work in this situation. I have used those for quite a few things in the past and never had an issue.
Re: Place an ARG inside another ARG in Service Check
Posted: Thu Feb 06, 2020 12:08 pm
by benjaminsmith
Hello
@jvaira,
The custom or free variable can work as well. What version of Nagios XI are you using? Also, you'll need to add SERVICE or HOST in front of the variable.
In order to prevent name collision among custom variables from different object types, Nagios prepends "_HOST", "_SERVICE", or "_CONTACT" to the beginning of custom host, service, or contact variables, respectively, in macro and environment variable names. The table below shows the corresponding macro and environment variable names for the custom variables that were defined in the example above.
https://assets.nagios.com/downloads/nag ... tvars.html