Writing Perl script
Stanley Hopcroft
Stanley.Hopcroft at IPAustralia.Gov.AU
Wed Apr 2 00:18:33 CEST 2003
Dear Gentlemen,
On Tue, Apr 01, 2003 at 09:20:22PM +0200, Gert Lindström wrote:
> Can some explain this for a perl newbi ?
>
> Explicitly initialize each varialable in use. Otherwise with caching enabled, the plugin will not be recompilied each time, and therefore Perl will not reinitialize all the variables. All old variable values will still be in effect.
>
This comment only applies to Perl programs written to use an embedded
Perl interpreter - such as Nagios built with the Perl configure options.
If Nagios is built --with-perl-cache (?), then the Perl plugin is _not_
recompiled each time it is scheduled by Nagios. This saves quite some
CPU cycles and is the same technique used by mod_perl to boost Perl CGI
performance.
See perldoc perlembed (man perlembed) or the mod_perl docco.
> I think this is happening for me and i cant figuring out what to do about it.
>
Initialise your variables before they are used. Don't expect them to
have null or zero values. Otherwise, they will probably retain the
values they had last time the program was run by the embedded Perl
Nagios.
my ($a, $b, $c) = qw(a b c) : # ?
my $i = 10
my @a = qw(a_0 a_1 a_2 a_3) ;
my %h = ( a => 1, b => 2) ;
# that's all
# for Perl > 5.6 ? 'use constant' is another reasonable initialiser.
If it is, rebuild Nagios without the Perl options (standalone test
Nag) and see if it still happens or use the contrib/mini_epn to check
your program out.
In nay case, it is a good thing to initiliase variables. If they were C
auto variables you'd get junk ...
> Thanks
>
> ---
> Gert
--
------------------------------------------------------------------------
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: ValueWeb:
Dedicated Hosting for just $79/mo with 500 GB of bandwidth!
No other company gives more support or power for your dedicated server
http://click.atdmt.com/AFF/go/sdnxxaff00300020aff/direct/01/
_______________________________________________
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