$ARG1$

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Post Reply
SoCalMike
Posts: 3
Joined: Wed Jun 26, 2024 3:03 pm

$ARG1$

Post 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.
User avatar
ajcoil
Posts: 108
Joined: Wed Aug 09, 2023 10:30 am

Re: $ARG1$

Post by ajcoil »

Hello @SoCalMike,

Thank you for reaching out!

For the "Command Line" part of your commands config, instead of:

Code: Select all

/path/to/bash.sh $ARG1$
Try:

Code: Select all

/path/to/bash.sh -H $ARG1$
Let me know if that helps!
SoCalMike
Posts: 3
Joined: Wed Jun 26, 2024 3:03 pm

Re: $ARG1$

Post 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
User avatar
ajcoil
Posts: 108
Joined: Wed Aug 09, 2023 10:30 am

Re: $ARG1$

Post 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!
kg2857
Posts: 490
Joined: Wed Apr 12, 2023 5:48 pm

Re: $ARG1$

Post 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.
SoCalMike
Posts: 3
Joined: Wed Jun 26, 2024 3:03 pm

Re: $ARG1$

Post 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.
swolf

Re: $ARG1$

Post 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:

Code: Select all

/path/to/bash.sh -H $HOSTADDRESS$
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
danielmese76
Posts: 2
Joined: Thu May 08, 2025 3:00 am

Re: $ARG1$

Post 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.
Andreaa23
Posts: 6
Joined: Mon Aug 07, 2023 10:06 pm

Re: $ARG1$

Post 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.
Post Reply