[Nagiosplug-devel] Tools for checking plugin ability to run against embedded Perl.

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Tue Jan 18 00:40:32 CET 2005


Dear Folks,

As part of the embedded Perl support for Nagios (and my own practise), 
there are 'tools' that validate whether or not a plugin will run 
reliably under an embedded Perl Nagios.

You can see a synopsis of the tools below.

These could be useful to the developers to test the conformance of the 
core Perl plugins, or perhaps useful for recommending to people having 
ePN trouble with their own plugins (as I did today privately).

I was thinking about putting the stuff on CPAN but this solves more 
problems for me rather than solves any for CPAN users. OTOH, it does 
seem to have more direct relavance here.

Obviously, this would be unsupported code, a subdir of contrib perhaps.

Finally, I apologise for yacking about my rubbish rather than 
contributing but this was part of the effort for 2.0 so it had to happen 
first.

However, there is some genuine benefit. Coding for embedded interpreters 
is likely to make for

1 more reliable code - must pass 'strict' pragma

2 faster code        - (if one uses lexical vars) since lexical vars 
favoured by strict pragma are allocated at compile time.

Code consists of a tarball. Some or all of it _may_ be bundled with Nag 
2.0.

Yours sincerely.

 -- 
Stanley Hopcroft

IP Australia
Ph: (02) 6283 3189  Fax: (02) 6281 1353
PO Box 200 Woden  ACT 2606
http://www.ipaustralia.gov.au

1 results of building (ie Perl setup) on FreeBSD

tsitc> make clean
rm -rf ./blib Makefile.aperl 
blib/arch/auto/Nagios/Persistent/extralibs.all 
blib/arch/auto/Nagios/Persistent/extralibs.ld perlmain.c tmon.out 
mon.out so_locations pm_to_blib *.o *.a perl.exe perl perl  
Persistent.bso Persistent.def libPersistent.def Persistent.exp 
Persistent.x core core.*perl.*.? *perl.core core.[0-9] core.[0-9][0-9] 
core.[0-9][0-9][0-9] core.[0-9][0-9][0-9][0-9] 
core.[0-9][0-9][0-9][0-9][0-9]
mv Makefile Makefile.old > /dev/null 2>&1

tsitc> perl Makefile.PL
Checking if your kit is complete...
Looks good
Writing Makefile for Nagios::Persistent

tsitc> make
cp Persistent.pm blib/lib/Nagios/Persistent.pm
cp p1.pl blib/lib/Nagios/p1.pl
Manifying Persistent.3

tsitc> make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" 
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/test....Use of uninitialized value in concatenation (.) or string at 
t/test.t line 235.
t/test....ok                                                                 
All tests successful.
Files=1, Tests=16,  1 wallclock secs ( 0.32 cusr +  0.05 csys =  0.37 
CPU)
tsitc> 

2 drive_epn.pl

tsitc> ./drive_epn.pl 
plugin command line: check_ok
embedded perl plugin return code and output was: 0 & Ok. In the 
beginning was the word and the word was with GOD.

plugin command line: check_ok
embedded perl plugin return code and output was: 0 & Ok. In the 
beginning was the word and the word was with GOD.

plugin command line: check_ok
embedded perl plugin return code and output was: 0 & Ok. In the 
beginning was the word and the word was with GOD.

plugin command line: check_atmoss_hack  
embedded perl plugin return code and output was: 0 & ATMOSS Transaction 
completed Ok.

plugin command line: check_adds_hack  
embedded perl plugin return code and output was: 0 & ADDS Transaction 
completed Ok.

plugin command line: You have new mail.
tsitc> 

3 mini_epn.c

tsitc> rm mini_epn
tsitc> make
perl -MExtUtils::Embed -e xsinit
cc -g -c perlxsi.c  `perl -MExtUtils::Embed -e ccopts`
cc -g -c mini_epn.c `perl -MExtUtils::Embed -e ccopts`
cc -g  perlxsi.o mini_epn.o `perl -MExtUtils::Embed -e ccopts -e ldopts` 
-o mini_epn
tsitc> ./mini_epn 
Enter file name: check_ok
embedded perl plugin return code and output was: 0 & 'Ok. In the 
beginning was the word and the word was with GOD.
'
Enter file name: check_adds_hack
embedded perl plugin return code and output was: 0 & 'ADDS Transaction 
completed Ok.
'
Enter file name: tsitc> 

4 drive_epn_loop.pl

tsitc> ./drive_epn_loop.pl 
check_rpc       (0, OK: RPC program portmapper version 2 udp running).
check_ntp       (0, NTP OK: Offset 0.000001 secs, jitter 0.437 msec, 
peer is stratum 1).
check_mailq     (3, **ePN 'check_mailq' Duplicate specification 
"Warning=i" for option "warning").
check_file_age  (0, OK - /bin/cat is 949596 seconds old and 69072 
bytes).
check_rpc       (3, UNKNOWN: RPC program portmapper  udp is not 
running).
check_ntp       (0, NTP OK: Offset -0.000001 secs, jitter 0.437 msec, 
peer is stratum 1).
check_mailq     (3, **ePN 'check_mailq' Duplicate specification 
"Warning=i" for option "warning").
check_file_age  (0, OK - /bin/cat is 949604 seconds old and 69072 
bytes).
check_rpc       (3, UNKNOWN: RPC program portmapper  udp is not 
running).
check_ntp       (0, NTP OK: Offset -0.000001 secs, jitter 0.437 msec, 
peer is stratum 1).
check_mailq     (3, **ePN 'check_mailq' Duplicate specification 
"Warning=i" for option "warning").
check_file_age  (0, OK - /bin/cat is 949612 seconds old and 69072 
bytes).
check_rpc       (3, UNKNOWN: RPC program portmapper  udp is not 
running).
check_ntp       (0, NTP OK: Offset -0.000001 secs, jitter 0.437 msec, 
peer is stratum 1).
^C
tsitc> 

## Looks like this old version of check_rpc needs some work for ePN

5 test_epn_arg1 (for shell loops).

tsitc> ./test_epn_arg1.pl check_ok 
(0, 'Ok. In the beginning was the word and the word was with GOD.').
tsitc> ./test_epn_arg1.pl check_adds_hack 
(0, 'ADDS Transaction completed Ok.').
tsitc> 

## no more docco.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: disclaimer.txt
URL: <http://nagios-plugins.org/archive/devel/attachments/20050118/4310b4f1/attachment.txt>


More information about the Devel mailing list