Re: Grrr. Embedded Perl argument processing breaks Perl service handlers.

Stanley Hopcroft <[email protected]>
Newsgroups gmane.network.netsaint.user
Message-ID <[email protected]>
Dear Ladies and Gentlemen,

I am writing to report the success of the patch suggested by Mr Ghosh to
deal with the problem of the embedded Perl Netsaint/Nagios (ePN)  not
being able to deal with quoted arguments containing 'spaces', quote
characters and so on.

In other words, prior to this patch the ePN would not have the same 
argument processing semantics as the ordinary Netsaint. 

For example,

1 plain netsaint args: 'In the beginning' was the "'word'"
                    =>  argc = 3 and 
                        argv[0] = In the beginning
                        argv[1] = was
                        argv[2] = the
                        argv[3] = "word"
2            ePN args: 'In the beginning' was the "'word'"
                   =>   argc = 6
                        argv[0] = 'In
                        argv[1] = the
                        argv[2] = beginning' ...
                        argv[5] = "'word'"

This ePN behaviour violates the POLA and leads to plugin failure.

Mr Ghoshs suggested patch to p1.pl (use Text::ParseWords, a standard 
module included wth Perl 5.00503 and _I hope_ with contemporary Perls) 
works fine with 

tsitc# ../bin/netsaint -m

NetSaint 0.0.7
Copyright (c) 1999-2002 Ethan Galstad ([email protected])
Last Modified: 03-01-2002
License: GPL

External Data Modules
---------------------
Object Data:    DEFAULT
Status Data:    DEFAULT
Retention Data: DEFAULT
Comment Data:   DEFAULT

Options
-------
* Embedded Perl compiler (With caching)

tsitc# ../libexec/ap5 'In the beginning was the' word and "the 'word' 
was with GOD"
$ARGV[1]: In the beginning was the $ARGV[2]: word $ARGV[3]: and 
$ARGV[4]: the 'word' was with GOD tsitc# 


tsitc# grep ap5 ../etc/commands.cfg
command[check_quoted_args]=$USER1$/ap5 $ARG1$ $ARG2$ $ARG3$ $ARG4$ 
$ARG5$ $ARG6$ 

tsitc# grep quoted ../etc/hosts.cfg
service[test]=Quoted argument for embedded Perl patch test 
(dev/debug);0;24x7;3;5;1;test-admins;120;24x7;1;1;1;;check_quoted_args!'In 
the beginning was the'!word!and!"the 'word' was with GOD"

tsitc# lynx -auth=yada:blah -dump 
'http://tsitc/cgi-bin/netsaint/extinfo.cgi?type=2&host=test&service=Quoted+argument+for+embedded+Perl+patch+test+%28dev%2Fdebug%29'

   Information For Service Quoted argument for embedded Perl patch test
   (dev/debug) On Host test
   Last Updated: Thu Oct 24 21:58:43 EST 2002
   Updated every 90 seconds
   NetSaint Network Monitor - [1]www.netsaint.org
   Logged in as anwsmh
   - NetSaint process is running
   - Notifications can be sent out (active mode)
   - Service checks are actively being executed

   ... <snip>

   Quoted argument for embedded Perl patch test (dev/debug)
   on
   Nonexistent host for Netsaint dev
   10.0.3.110
   
   Service State Information
   Variable Value
   Current Status
     OK
   Status Information $ARGV[1]: In the beginning was the $ARGV[2]: word
   $ARGV[3]: and $ARGV[4]: the 'word' was with GOD
   Current Attempt 1/3
   State Type HARD
   Last Check Type ACTIVE
   Last Check Time 24-10-2002 21:56:44
   Next Scheduled Active Check 24-10-2002 22:01:44
   Latency 0 seconds
   Check Duration 0 seconds
   Service Checks Enabled?
     YES

So, the patch works for my Netsaint ePN sample of 1.

This is now running in production with no adverse impact on the 
fairly large number of Perl plugins used here.

There are still issues with ePN (eg
1 can't run checks using some modules such as HTML::Parser
2 can't run checks using tie) but this is a step forward.


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.


-------------------------------------------------------
This sf.net email is sponsored by: Influence the future 
of Java(TM) technology. Join the Java Community 
Process(SM) (JCP(SM)) program now. 
http://ad.doubleclick.net/clk;4729346;7592162;s?http://www.sun.com/javavote
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.