ARG fields in service checks
ARG fields in service checks
Hi,
I am currently looking to see if there a way of using a NAGIOS variable (like $HOSTADDRESS$) in the content of an $ARGx$ field. Already tried it but at the runtime is it used literally, not expanded ("$HOSTADDRESS$" instead the actual hostname interpretation).
Is there a hint/trick to make use of these in the $ARG$ (without having to write another command..)?
Thanks!
I am currently looking to see if there a way of using a NAGIOS variable (like $HOSTADDRESS$) in the content of an $ARGx$ field. Already tried it but at the runtime is it used literally, not expanded ("$HOSTADDRESS$" instead the actual hostname interpretation).
Is there a hint/trick to make use of these in the $ARG$ (without having to write another command..)?
Thanks!
Re: ARG fields in service checks
You should be able to use them in any command/$ARGn$ input and it should be expanded properly.
If it's not working with the Run Check Command button, try applying configuration and forcing a check to see if that works.
You can see the macros and what context they are available in here (which shows $HOSTADDRESS$ available in all contexts):
https://assets.nagios.com/downloads/nag ... olist.html
Can you post your service definition so I can see how you have it setup? Or you can PM me a copy of your profile.zip from Admin > System Profile > Download Profile button.
Thank you!
If it's not working with the Run Check Command button, try applying configuration and forcing a check to see if that works.
You can see the macros and what context they are available in here (which shows $HOSTADDRESS$ available in all contexts):
https://assets.nagios.com/downloads/nag ... olist.html
Can you post your service definition so I can see how you have it setup? Or you can PM me a copy of your profile.zip from Admin > System Profile > Download Profile button.
Thank you!
Re: ARG fields in service checks
well, let's say I used another way to avoid the need for that. But for the sake of knowledge, the $ARG1$ string for a snmp check service was containing data like :
$ARG1$ = -v3 -u '$HOSTADDRESS$_user' -A 'secret1' -x 'AES' -X 'secret1' -a 'SHA' -l 'authPriv'
where the snmpv3 username would have been something like switch1_user.
Using a template for the service would have required variabilizing the user form like $HOSTADDRESS$_user. It didn't happen and the $HOSTADDRESS$_user was sent literally while using the Run Check Command with any host.
$ARG1$ = -v3 -u '$HOSTADDRESS$_user' -A 'secret1' -x 'AES' -X 'secret1' -a 'SHA' -l 'authPriv'
where the snmpv3 username would have been something like switch1_user.
Using a template for the service would have required variabilizing the user form like $HOSTADDRESS$_user. It didn't happen and the $HOSTADDRESS$_user was sent literally while using the Run Check Command with any host.
Re: ARG fields in service checks
I'm still not able to reproduce:
I added this:
Which resulted in:
What was your command definition? What XI version are you running?
I added this:
Code: Select all
define command {
command_name atest
command_line $USER1$/check_output.sh $ARG1$
}Code: Select all
[root@xid tmp]# cat /usr/local/nagios/libexec/check_output.sh
#!/bin/bash
echo "$@" >> /usr/local/nagiosxi/tmp/test.txt
exit 0
Code: Select all
define service {
host_name XXXXXXXXXXX
service_description atest
check_command atest!-v3 -u '$HOSTADDRESS$_user' -A 'secret1' -x 'AES' -X 'secret1' -a 'SHA' -l 'authPriv'!!!!!!!Code: Select all
[root@xid tmp]# cat /usr/local/nagiosxi/tmp/test.txt
-v3 -u 192.168.X.X_user -A secret1 -x AES -X secret1 -a SHA -l authPrivRe: ARG fields in service checks
oh,
indeed that seems to be working from the example you gave (as I expected also on my side).
Well, the command is a modified version of /usr/local/nagios/libexec/check_ifoperstatnag to allow checking fopr other things than ifOperStatus (like ifInErrors)
Definition of the serrvice (in GUI) is like
Then using the Run Check Command (in GUI, for localhost, for the sake of example) gives:
I was expecting 127.0.0.1 to be expanded also on $HOSTADDRESS$
NagiosXi is something between version 5.7.2 - 5.7.4 (how do i check for the exact version ??
)
indeed that seems to be working from the example you gave (as I expected also on my side).
Well, the command is a modified version of /usr/local/nagios/libexec/check_ifoperstatnag to allow checking fopr other things than ifOperStatus (like ifInErrors)
Code: Select all
define command {
command_name check_xi_service_ifgenstat
command_line $USER1$/check_ifgenstat $ARG1$ $ARG2$ $HOSTADDRESS$ $ARG3$
}Code: Select all
$USER1$/check_ifgenstat $ARG1$ $ARG2$ $HOSTADDRESS$ $ARG3$Code: Select all
$ARG1$ = 1
$ARG2$ = -v3 -u '$HOSTADDRESS$_polling' -A 'secret1' -x 'AES' -X 'secret1' -a 'SHA' -l 'authPriv'
$ARG3$ = ifInErrorsCode: Select all
/usr/local/nagios/libexec/check_ifgenstat 1 -v3 -u '$HOSTADDRESS$_polling' -A 'secret1' -x 'AES' -X 'secret1' -a 'SHA' -l 'authPriv' 127.0.0.1 ifInErrorsNagiosXi is something between version 5.7.2 - 5.7.4 (how do i check for the exact version ??
You do not have the required permissions to view the files attached to this post.
Re: ARG fields in service checks
Hi,
The "$HOSTADDRESS$" or "$HOSTADDRESS$_polling" will not be expended if it is defined inside any $ARG#$ value .... like $ARG1$, $ARG2$ ... etc.
Those must be defined on the "command_line" (below) only.
For this to works, please try the followings:
Definition of the serrvice (in GUI) is like:
Best Regards,
Vinh
The "$HOSTADDRESS$" or "$HOSTADDRESS$_polling" will not be expended if it is defined inside any $ARG#$ value .... like $ARG1$, $ARG2$ ... etc.
Those must be defined on the "command_line" (below) only.
For this to works, please try the followings:
Code: Select all
define command {
command_name check_xi_service_ifgenstat
command_line $USER1$/check_ifgenstat 1 -v3 -u "$HOSTADDRESS$_polling" $ARG1$ $HOSTADDRESS$ $ARG2$
}
Code: Select all
$USER1$/check_ifgenstat 1 -v3 -u "$HOSTADDRESS$_polling" $ARG1$ $HOSTADDRESS$ $ARG2$
Code: Select all
$ARG1$ = -A 'secret1' -x 'AES' -X 'secret1' -a 'SHA' -l 'authPriv'
$ARG2$ = ifInErrors
Best Regards,
Vinh
Re: ARG fields in service checks
Thank you, Vinh!.
I will take that into consideration.
This topic can be closed.
I will take that into consideration.
This topic can be closed.
-
scottwilkerson
- DevOps Engineer
- Posts: 19396
- Joined: Tue Nov 15, 2011 3:11 pm
- Location: Nagios Enterprises
- Contact:
Re: ARG fields in service checks
Locking threadTethiS wrote:Thank you, Vinh!.
I will take that into consideration.
This topic can be closed.