AW: check_command $ARGx$ with SPACE characters ?

Volker.Aust at premiere.de Volker.Aust at premiere.de
Tue Oct 8 18:48:10 CEST 2002


My experience with spaces in args is that it does not work if you compiled
Nagios with embedded perl. Without embedded perl Nagios calls a shell and
this shell calls the plugin. The shell groups everything between two ' or "
to one argument. With embedded perl Nagios calls the script without a shell
and Nagios does seperate the args between spaces.

For the one script I have wrote that need spaces in arguments I escape
spaces (with %20) and percent-signs (with %25) and decode the string in the
perl script with:

# dieser RE kommt aus uri_unescape() aus dem modul URI::Escape
$argument =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg;

You call your plugin with:

	check_command	check_fugger!1234!test%20param1%20param2

Hope this helps...

-vol

> -----Original Message-----
> From: Freddy Frouin [mailto:freddy.frouin at fluxus.net]
> Sent: Tuesday, October 08, 2002 6:19 PM
> To: Thomas Zahari
> Cc: nagios-users at lists.sourceforge.net
> Subject: Re: AW: [Nagios-users] check_command $ARGx$ with SPACE
> characters ?
> 
> 
> strange... I think that nagios or netsaint has always extract command
> args between chars !, so if you do somthing like:
> 
> command_def		my_path_to_plugin $SOME_MACRO$ [...] 
> "$ARG1$" '$ARG2$'
> 
> and then:
> 
> command_dec		check_my_plugin!test!test param1 param2
> 
> you could be sure that nagios or netsaint is running:
> 
> my_path_to_plugin $SOME_MACRO$ [...] "test" 'test param1 param2'
> 
> I think you need help comming from some netsaint and nagios guru ! ;)
> I hope some of them will answer to you.
> 
> 'will be interrested to see how this will be solved.
> 
> Freddy.
> 
> On Tue, 8 Oct 2002 17:42:34 +0200
> "Thomas Zahari" <thza at whatevermobile.com> wrote:
> 
> > Hi Freddy,
> > 
> > thank you for the very fast answer.
> > 
> > I tryed it already with the ", but it also dosent work.
> > On the linux system we use the bash shell with SuSE 7.3.
> > I checked my script and it works fine with the parameter in the ' !
> > Could it a problem with the nagios system. That calls the 
> external process
> > like
> > 
> > /check_fogger "1234" "'test" "param1" "param2'"
> > 
> > ????
> > 
> > Regards
> > Thomas
> > 
> > -----Ursprüngliche Nachricht-----
> > Von: Freddy Frouin [mailto:freddy.frouin at fluxus.net]
> > Gesendet: Dienstag, 8. Oktober 2002 17:09
> > An: Thomas Zahari
> > Cc: nagios-users at lists.sourceforge.net
> > Betreff: Re: [Nagios-users] check_command $ARGx$ with SPACE 
> characters ?
> > 
> > 
> > Hi,
> > 
> > 	I'm not sure to understand really why it goes like you said, yet
> > 	did you simply try to use "$ARG2$" instead of '$ARG2$'. Maybe
> > 	it's just a stupid suggestion, yet i'm using " char there, and
> > 	I've no problem like this...
> > 
> > 	Did you tryed to run you perl script like this to see 
> what happend:
> > 	./check_fogger 1234 'test param1 param2'
> > 
> > 	Maybe it is just the shell which is used to start this command
> > 	./check_fogger 1234 'test param1 param2' which do not recognize
> > 	char ' as a char to enclose arguments... What shell is using
> > 	the user starting nagios ?
> > 
> > 'hope this help,		Freddy.
> > 
> > On Tue, 8 Oct 2002 16:53:06 +0200
> > "Thomas Zahari" <thza at whatevermobile.com> wrote:
> > 
> > >
> > > Hello Nagios-Users,
> > >
> > > I try to use a check_command with a $ARGx$. But the 
> argument can have
> > space
> > > characters in it.
> > >
> > > I tried so much but nothing works.
> > >
> > > My config:
> > >
> > > 
> --------------------------------------------------------------
> ------------
> > --
> > > --
> > > # 'check_fugger' command definition
> > > define command{
> > >         command_name    check_fugger
> > >         command_line    $USER2$/fugger_check.pl 
> $HOSTADDRESS$ $ARG1$
> > > '$ARG2$'
> > >         }
> > >
> > > # Service definition
> > > define service{
> > >         use                             generic-service   
>       ; Name of
> > > service template to use
> > >
> > >         host_name                       server
> > >         service_description             Service1
> > >         is_volatile                     0
> > >         check_period                    24x7
> > >         max_check_attempts              3
> > >         normal_check_interval           10
> > >         retry_check_interval            1
> > >         contact_groups                  linux-admins
> > >         notification_interval           20
> > >         notification_period             24x7
> > >         notification_options            w,u,c,r
> > >
> > >         check_command                   
> check_fugger!1234!test param1
> > param2
> > >         }
> > >
> > > # Service definition
> > > define service{
> > >         use                             generic-service   
>       ; Name of
> > > service template to use
> > >
> > >         host_name                       server
> > >         service_description             Service2
> > >         is_volatile                     0
> > >         check_period                    24x7
> > >         max_check_attempts              3
> > >         normal_check_interval           10
> > >         retry_check_interval            1
> > >         contact_groups                  linux-admins
> > >         notification_interval           20
> > >         notification_period             24x7
> > >         notification_options            w,u,c,r
> > >
> > >         check_command                   
> check_fugger!2345!test param1
> > >         }
> > >
> > > 
> --------------------------------------------------------------
> ------------
> > --
> > >
> > > My fugger_check.pl script should get something like:
> > >
> > > ARGV[0]=192.168.1.1
> > > ARGV[1]=1234
> > > ARGV[2]=test param1 param2
> > >
> > > or
> > >
> > > ARGV[0]=192.168.1.1
> > > ARGV[1]=2345
> > > ARGV[2]=test param1
> > >
> > > but the perl script got this:
> > >
> > > ARGV[0]=192.168.1.1
> > > ARGV[1]=1234
> > > ARGV[2]='test
> > > ARGV[3]=param1
> > > ARGV[4]=param2'
> > >
> > > why ?????????
> > >
> > >
> > > I hope you can help me !
> > >
> > > Thank you !!
> > > Thomas
> > >
> > >
> > >
> > > -------------------------------------------------------
> > > This sf.net email is sponsored by:ThinkGeek
> > > Welcome to geek heaven.
> > > http://thinkgeek.com/sf
> > > _______________________________________________
> > > Nagios-users mailing list
> > > Nagios-users at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/nagios-users
> > >
> > 
> > 
> > --
> > Freddy Frouin
> > Responsable Supervision
> > Fluxus - British Telecom
> > 30, rue du Château des Rentiers
> > 75013 Paris
> > 
> > Tél: +33 (0)1 44 97 70 00
> > Fax: +33 (0)1 44 97 70 07
> > 
> > 
> > 
> > -------------------------------------------------------
> > This sf.net email is sponsored by:ThinkGeek
> > Welcome to geek heaven.
> > http://thinkgeek.com/sf
> > _______________________________________________
> > Nagios-users mailing list
> > Nagios-users at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/nagios-users
> > 
> 
> 
> -- 
> Freddy Frouin
> Responsable Supervision
> Fluxus - British Telecom
> 30, rue du Château des Rentiers
> 75013 Paris
> 
> Tél: +33 (0)1 44 97 70 00
> Fax: +33 (0)1 44 97 70 07
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Nagios-users mailing list
> Nagios-users at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/nagios-users
> 


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf




More information about the Users mailing list