Using arguments in Alias commands NSClient++

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
cfgriffith
Posts: 83
Joined: Tue Jan 15, 2013 4:22 pm

Using arguments in Alias commands NSClient++

Post by cfgriffith »

I have a generic service check alias that I use on all my boxes. I want to be able to exclude services via argument lines in Nagios XI.

I have written the following check:

alias_service = checkServiceState CheckAll? "exclude=ShellHWDetection" "exclude=clr_optimization_v4.0.30319_32" "exclude=clr_optimization_v4.0.30319_64" "exclude=clr_optimization_v2.0.50727_32"
I know NSClient++ is a separate product, but I think what I may be doing wrong might be something on the Nagios XI side.

"exclude=clr_optimization_v4.0.30319_32" "exclude=SysmonLog?" "exclude=VMUpgradeHelper" "exclude=HealthService?" "exclude=0193831367257817mcinstcleanup" "exclude=iphlpsvc" "exclude=stisvc" "exclude=SplunkForwarder?" "exlude=TSM Client Scheduler" "exclude=Contego_Spop" "exclude=$ARG2" "exclude=$ARG3$" "exclude=$ARG4$"

This check excludes certain static services that are commonly excluded on all boxes. In addition I added argument lines so I could add service to be excluded in Nagios XI, without having to make configuration changes on individual servers.

The service I am trying to exclude in this case is: IBMWAS70Service - Tivoli Integrated Portal - TIPProfile_Port_16310

When I write a static exclusion into the config, the service is excluded, but when I try to exclude it using it as an argument:

check_nrpe!alias_service!IBMWAS70Service - Tivoli Integrated Portal - TIPProfile_Port_16310!

The service is not excluded. Is there something I am doing wrong?

Thanks.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Using arguments in Alias commands NSClient++

Post by slansing »

I would say you need to follow the exact same syntax you have on the NSclient++ side to make a valid test of this, that means using the following type of exclusion in the arguments in Nagios XI:

Code: Select all

 "exclude=ShellHWDetection"
cfgriffith
Posts: 83
Joined: Tue Jan 15, 2013 4:22 pm

Re: Using arguments in Alias commands NSClient++

Post by cfgriffith »

So like check_nrpe!alias_service!"exclude=IBMWAS70Service - Tivoli Integrated Portal - TIPProfile_Port_16310"! instead of trying to call an argument?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Using arguments in Alias commands NSClient++

Post by slansing »

No, they all appear to be separate services correct? Separate them the way I showed above, not with a nasty character "-" in between, unless that is the correct syntax. It does look like you already have them excluded on the NSClient++ side though.. correct? Then you don't need nagios to pass an argument.
cfgriffith
Posts: 83
Joined: Tue Jan 15, 2013 4:22 pm

Re: Using arguments in Alias commands NSClient++

Post by cfgriffith »

Oh, I see what your saying. No that's just one extremely long service name. I know when I make an exception for it statically in the config the exception works so it's not the - messing it up, unless -'s have some special meaning when it comes to arguments.

The ones I have specifically excluded, like the one you gave me in your example. Work fine. What I'm trying to do is make the alias so I can use the Argument fields in Nagios XI to specify specific services not already excluded in that list, and exclude them as well.

so if I put BLAH in ARG2 in Nagios XI, it would be the equivalent of typing "exclude=BLAH" in the config on the server.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Using arguments in Alias commands NSClient++

Post by lmiltchev »

You can have the following in the NSC.ini (or nsclient.ini, depending on the NSClient++ version):

Code: Select all

alias_service = checkServiceState CheckAll "exclude=ShellHWDetection" "exclude=clr_optimization_v4.0.30319_32" "exclude=clr_optimization_v4.0.30319_64" "exclude=clr_optimization_v2.0.50727_32" $ARG1$
Then, you can run from the nagios server:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <client_IP> -c alias_service -a "exclude=BLAH"
Be sure to check out our Knowledgebase for helpful articles and solutions!
cfgriffith
Posts: 83
Joined: Tue Jan 15, 2013 4:22 pm

Re: Using arguments in Alias commands NSClient++

Post by cfgriffith »

Should I add $ARG1$ and $ARG2$ so I can make multiple exclusions or would I just have to type /usr/local/nagios/libexec/check_nrpe -H <client_IP> -c alias_service -a "exclude=BLAH" "exclude=BLAH2"
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Using arguments in Alias commands NSClient++

Post by slansing »

You could do it either way, "I believe." Either hard coded, or set as an argument, and then that argument must be set in the NSClient.ini file as $ARG2$ as well.
cfgriffith
Posts: 83
Joined: Tue Jan 15, 2013 4:22 pm

Re: Using arguments in Alias commands NSClient++

Post by cfgriffith »

When I try
lmiltchev wrote:You can have the following in the NSC.ini (or nsclient.ini, depending on the NSClient++ version):

Code: Select all

alias_service = checkServiceState CheckAll "exclude=ShellHWDetection" "exclude=clr_optimization_v4.0.30319_32" "exclude=clr_optimization_v4.0.30319_64" "exclude=clr_optimization_v2.0.50727_32" $ARG1$
Then, you can run from the nagios server:

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H <client_IP> -c alias_service -a "exclude=BLAH"
In Nagios I get this return:

Exception processing request: Request contained arguments (not currently allowed, check the allow arguments option).
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Using arguments in Alias commands NSClient++

Post by lmiltchev »

Did you check if "allow_arguments" is set to "1" in the NSC.ini file?

Code: Select all

allow_arguments=1
If you modify this line you need to restart the NSClient++ service, so that changes can take effect.

Note: There should be a few of these lines in the file - in the external scripts section, nrpe section, etc.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked