Macros in service checks ..
Stanley Hopcroft
Stanley.Hopcroft at IPAustralia.Gov.AU
Sat Jan 17 07:27:21 CET 2004
Dear Sir,
I am writing to thank you for your letter and say,
On Fri, Jan 16, 2004 at 08:01:15PM -0800, nagios-users-request at lists.sourceforge.net wrote:
>
> On Fri, 16 Jan 2004, Brian E. Seppanen wrote:
>
> > I have a command definition that includes
> >
> > command_line $USER1$/check_something -H $HOSTADDRESS$ -C $ARG1$
> >
> > Often times I have a different argument that needs to be passed to -C
> >
> > So I have various macros defined
> >
> > $USER5$=A
> > $USER6$=B
> > $USER7$=C
> >
> > In my service definition I'm trying to do the following
> >
> > define service{
> > use telepathic-service
> >
> >
> > hostgroup_name something
> > service_description TEST
> > is_volatile 0
> > check_period 24x7
> > max_check_attempts 2
> > normal_check_interval 15
> > retry_check_interval 2
> > contact_groups me,myself,andi
> > notification_interval 60
> > notification_period 24x7
> > notification_options c,r
> > check_command check_something!$USER5$
> > register 1
> > }
> >
> > It does not appear that $USER15$ is passed as $ARG1$ however
> >
> > as I get invalid argument =
> >
> > from check_something.
> >
> > Is there any way around this?
> >
>From the docco macros are available from $USER1$ to 32$, and the values
set in the resource config file (see the sameple).
Is this how you are setting the value of $USER15$ ?
There may be a docco or Nag macro bug involved.
It would be useful to do any of
1 Post the exact error message, and where it was reported.
I can't find 'invalid argument' in the Nag sources except for the CGIs
(and this doesn't seem to be the right place).
tsitc> grep -i -2 -r 'invalid argument' * | more
cgi/config.c- }
cgi/config.c-
cgi/config.c: /* we recieved an invalid argument */
cgi/config.c- else
cgi/config.c- error=TRUE;
--
cgi/showlog.c- display_timebreaks=FALSE;
cgi/showlog.c-
cgi/showlog.c: /* we recieved an invalid argument */
cgi/showlog.c- else
cgi/showlog.c- error=TRUE;
--
cgi/tac.c- display_header=FALSE;
cgi/tac.c-
cgi/tac.c: /* we recieved an invalid argument */
cgi/tac.c- else
cgi/tac.c- error=TRUE;
tsitc>
2 Post the macro values/check them for characters that are forbidden
3 Look for the boundary cases
Does it work for _any_ $USERn$ Macro ?
How far can you get in setting $USERn$ ?
4 Consider firing up a newly configured Nag with the appropriate DEBUGn
option to configure, with a --prefix to a sandbox (ie _non_ production
path) that you can give a cutdown config to and maybe run in foreground
to capture the fault errors.
Maybe DEBUG1, (or DEBUG2 and or DEBUG3) will help.
If you think this is a bug, it would be helpful to report it with some
of this information.
5 Have a look at the CVS log on Nagios.ORG for the checkin messages on
the bug fix branch. Some bugs have been corrected _only_ in this branch.
However, I have a feeling you are out of luck, since I would gues that
the check_command in services.cfg is _not_ scanned for macros; only the
check_command in checkcommands.cfg.
Dumb work around ?= pass the service check coded values that the corresp
plugin decodes.
Could be stupidly like
check_something!A_B_C_D_E!n
# 0 1 2 3 4
Meanwhile back in your plugin (Perl illustration):
my $arg_string = shift @ARGV;
my $arg_index = shift @ARGV;
my @args = split(/_/, $arg_string) ;
my $arg = ( $arg_index <= 4 and $arg_index >=
0) ? $args[$arg_index] : &outahere('bad arg', $arg_index);
==> Involves hacking plugins.
Yours sincerely.
--
------------------------------------------------------------------------
Stanley Hopcroft
------------------------------------------------------------------------
'...No man is an island, entire of itself; every man is a piece of the
continent, a part of the main. If a clod be washed away by the sea,
Europe is the less, as well as if a promontory were, as well as if a
manor of thy friend's or of thine own were. Any man's death diminishes
me, because I am involved in mankind; and therefore never send to know
for whom the bell tolls; it tolls for thee...'
from Meditation 17, J Donne.
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list