Page 1 of 1
$ARG1$
Posted: Wed Jun 26, 2024 3:10 pm
by SoCalMike
I have a service that runs from a bash script that relies on one command line argument.
I created a command with command line /path/to/bash.sh $ARG1$
I created a service with the check command and added 1 host to it
IN the host config, I added -H 192.168.1.2 in ARG1 field.
The host is not passing off the ARG1 field for some reason.
For the life of me I can't figure out what I'm doing wrong. Any help is appreciated.
Re: $ARG1$
Posted: Wed Jun 26, 2024 4:55 pm
by ajcoil
Hello
@SoCalMike,
Thank you for reaching out!
For the "Command Line" part of your commands config, instead of:
Try:
Let me know if that helps!
Re: $ARG1$
Posted: Thu Jun 27, 2024 10:48 am
by SoCalMike
Hi AJcoil
Thanks for the help!
I did as you suggested. The command line variable still isn't getting passed off from the host config.
Command is now
/path/to/bash.sh -H $ARG1$
In the Service Config, $ARG1$ field is blank
In the Host Config, $ARG1$ field is populated
Re: $ARG1$
Posted: Thu Jun 27, 2024 11:19 am
by ajcoil
Hello
@ SoCalMike,
Thank you for getting back to me!
After rereading your issue, I think the issue might relate to the host/service structure.
You will want the add the command and fill out the ARG fields in the
service of your host.
Do let me know if this helps!
Re: $ARG1$
Posted: Fri Jun 28, 2024 4:02 am
by kg2857
Maybe the OP should post the command and service text.
I'd also ask what is bash.sh? Might want to post that as text as well.
Re: $ARG1$
Posted: Fri Jun 28, 2024 12:38 pm
by SoCalMike
ajcoil wrote: ↑Thu Jun 27, 2024 11:19 am
Hello
@ SoCalMike,
Thank you for getting back to me!
After rereading your issue, I think the issue might relate to the host/service structure.
You will want the add the command and fill out the ARG fields in the
service of your host.
Do let me know if this helps!
It definitely works that way. I was trying to avoid having to create a separate service for each server that needs to use this service.
Re: $ARG1$
Posted: Mon Jul 01, 2024 10:47 am
by swolf
Hi
@SoCalMike,
I think you'll want to use the built-in macros instead of user argument ("ARG") macros.
Try setting your check command to this:
Then set up a service that uses this command. In addition, I'm going to recommend that you put the service onto a
host group and add all of the relevant servers' host entries to that hostgroup. That way you can just manage one service entry for the check you want to run.
Here is a full list of the built-in macros. If you find that you want to set custom macros per-host, you can also use
Custom Object Variables.
Hopefully that helps, and please let me know if anything needs clarification.
-Sebastian
Re: $ARG1$
Posted: Thu May 08, 2025 3:03 am
by danielmese76
Thanks @swolf, that clears it up a lot.
I was definitely overcomplicating things trying to handle each server individually. Using
drive mad $HOSTADDRESS$ and setting up a hostgroup makes way more sense, especially since the script is the same across the board. Appreciate the tip on avoiding $ARGn$ for this—I'll switch over to built-in macros.
Re: $ARG1$
Posted: Thu Jul 10, 2025 2:28 am
by Andreaa23
You’ve defined $ARG1$ in the command
slither io definition, and expected it to be pulled from the host config's ARG1 field, but Nagios doesn’t do that.