[Nagiosplug-devel] (Fwd) Plugins 2 SQL

Stanley Hopcroft Stanley.Hopcroft at IPAustralia.Gov.AU
Wed Mar 10 18:56:10 CET 2004


On Wed, Mar 10, 2004 at 08:04:49PM -0600, Ethan Galstad wrote:
> 
> ------- Forwarded message follows -------
> From:           	"AJ McKee" <aj.mckee at nmtbmedia.com>
> 
> Howdy all again,
> 
> Just sitting thinking here especially over the whole up.time thinghy.
> Its not a bad idea to have the plugins output be entered into a sql
> server of some type.

>  So I am think of giving it a go in perl if there
> are no plans to do the same or no one else is doing this. 
> 

FWIW, this can be done very easily and almost transparently for the Perl 
plugins using another approach

Have utils.pm tie the main::STDOUT filehandle to an object (ie
subroutines in a package) that logically 'tees' the output to both
STDOUT (the normal print function is only intercepted by Perl in the
client code that asks for the tie) and the DB.

Likewise CORE::exit can be redefined (not tied) to do perform the
database update and call exit.

Examples of both techniques are in p1.pl (HEAD especially) and there
are a lot of examples of getting user defined behaviour from 
standard Perl variables and handles by tie'ing in 'Programming Perl'

Tie imposes a performance hit but may be an alternative approach 
(although it would see that Mr McKees approach of wrapping each plugin 
in code that runs the plugin, updates the DB and then passes the result 
back could be done by checks.c without the performance hit and for all 
plugins).

> 
> ------- End of forwarded message -------
> 

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.




More information about the Devel mailing list