[Nagios-devel] Grrr. Embedded Perl argument processing breaks Perl service handlers.

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
Guest

[Nagios-devel] Grrr. Embedded Perl argument processing breaks Perl service handlers.

Post by Guest »

Dear Ladies and Gentlemen,

I am writing to report being burned by a known problem that would be
nice to fix with the emedded Perl Netsaint/Nagios (ePN).

The problem is that the ePN driver program p1.pl does not do shell like
processing of the command line arguments ie

what the shell sees as

'In the beginning was the word' ( 1 argument)

is seen by the Perl program that eventually is called as

'In' 'the' 'beginning' 'was' 'the' 'word'. (6 arguments).

This is not such a bad problem for service checks but it is very bad for
service handlers that need to be able to examine the $servicestate$ and
$statetype$ macro values.

If one has multi word service description and one wants to keep the
$ouput$ value (in a database for example as part of an availability
reporting hook) then the handler sees something like

Thu Jan 1 10:00:00 1970 $ARGV[0]: 1035167718
Thu Jan 1 10:00:00 1970 $ARGV[1]: mvs
Thu Jan 1 10:00:00 1970 $ARGV[2]: "Batch
Thu Jan 1 10:00:00 1970 $ARGV[3]: reports
Thu Jan 1 10:00:00 1970 $ARGV[4]: via
Thu Jan 1 10:00:00 1970 $ARGV[5]: email"

instead of

Thu Jan 1 10:00:00 1970 $ARGV[0]: 1035167718
Thu Jan 1 10:00:00 1970 $ARGV[1]: mvs
Thu Jan 1 10:00:00 1970 $ARGV[2]: Batch reports via Email
Thu Jan 1 10:00:00 1970 $ARGV[3]: CRITICAL
Thu Jan 1 10:00:00 1970 $ARGV[4]: HARD
Thu Jan 1 10:00:00 1970 $ARGV[5]: Connection refused or timed out

Obviously this is real bad because the service handler fails to see the

. correct service description
. state type
. service state

Note that this occurs when the multi word macros are quoted in the
command defintions.

command[global-svc-handler]=$USER1$/global_svc_handler $TIMET$
$HOSTNAME$ "$SERVICEDESC$" $SERVICESTATE$ $STATETYPE$ "$OUTPUT$"

I think the problem is that the arguments to the plugin are simply sent
as a string value in the third argument to the perl_call_argv

(

if(strchr(processed_command,' ')==NULL)
args[3]="";
else
args[3]=processed_command+strlen(fname)+1;

/* call our perl interpreter to compile and optionally
cache the command */

perl_call_argv("Embed::Persistent::eval_file", G_DISCARD | G_EVAL, args)

)

what needs to be done is that argv[3..] needs to contain _each_ of the
arguments from argv.

In the meantime, if your service handlers don't run as you expect -
despite their being scheduled - it may be ePN that is the problem.

The workaround is a C wrapper.

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 post was automatically imported from historical nagios-devel mailing list archives
Original poster: Stanley.Hopcroft@IPAustralia.Gov.AU
Locked