Trying to understand $ARG$

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
toleolu
Posts: 294
Joined: Fri Jul 19, 2013 7:02 pm
Location: Honolulu Hawaii

Trying to understand $ARG$

Post by toleolu »

I copied this code from a post on the forum, hoping I could use this to see if I understand this macro.

This line comes from the posters command.cfg file:

command_line $USER1$/check_nt -H ~HOSTADDRESS$ -p 12489 -s <passwd> -v FILEAGE -l $ARG1$ -w $ARG2$ -c $ARG3$

Then in the services definition file there's this line:

check_command check_nt_fileage!"c:\\epoca\\temp\\nani.ftp" -w2 -c5

Is -w2 the value for $ARG2$ and -c5 the value for $ARG3$? And if that's correct, where is $ARG1$?

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

Re: Trying to understand $ARG$

Post by slansing »

In service definitions ARG's are separated by "!'s", hence, you would need to add additional "!'s" after each text string to denote the following text being set to the next numerically listed argument.

In other words, if you are trying to use all of those arguments you would define your service like so:

Code: Select all

check_command check_nt_fileage!"c:\\epoca\\temp\\nani.ftp"!2!5 
You should not need to have the added "-w2 or -c5" in there as that would double up the already hard coded values in the command, as well as not having the proper space after them.
sreinhardt
-fno-stack-protector
Posts: 4366
Joined: Mon Nov 19, 2012 12:10 pm

Re: Trying to understand $ARG$

Post by sreinhardt »

Just as a warning, HOSTADDRESS should also have $s around it. Otherwise, the $arg#$ variables are used in check definitions to accept values from host or service check definitions. The arguments are separated by !, so in your example:

Command(check_nt): command_line $USER1$/check_nt -H ~HOSTADDRESS$ -p 12489 -s <passwd> -v FILEAGE -l $ARG1$ -w $ARG2$ -c $ARG3$
Service Check: check_nt!password!c:\path\to\file!30!45

Arg1 = password
Arg2 = c:\path\to\file
Arg3 = warning value
Arg4 = critical value

These are completely variable for each definition and you may use all, some, or none of them.
Nagios-Plugins maintainer exclusively, unless you have other C language bugs with open-source nagios projects, then I am happy to help! Please pm or use other communication to alert me to issues as I no longer track the forum.
toleolu
Posts: 294
Joined: Fri Jul 19, 2013 7:02 pm
Location: Honolulu Hawaii

Re: Trying to understand $ARG$

Post by toleolu »

Thanks
Locked