Nagios::* namespace accepted on CPAN.

Patrick LeBoutillier patrick_leboutillier at hotmail.com
Thu May 29 13:53:09 CEST 2003


I'm very pleased with this.

I also have NagiosPlugin.pm, that could be renamed Nagios::Plugin.pm, an
object oriented
wrapper to create Perl Nagios Plugins. You basically use it like this,
implementing the usage(),
validate_options() and test() methods:

-----------------------------------
#!/usr/bin/perl

package check_xxx ;
@ISA = qw(NagiosPlugin) ;

use strict ;
use NagiosPlugin ;

sub new {
    my $class = shift ;
    my $this = $class->SUPER::new('check_xxx', '1.0', "-H=s", "-p=i",
"-t=i") ;
}

sub usage {
    my $this = shift ;
    return "Usage: check_xxx.pl -H host -p port [-t timeout]\n" ;
}

sub validate_options {
    my $this = shift ;
    if ((! $this->{opts}->{H})||(! $this->{opts}->{p})){
        die($this->usage()) ;
    }
}

sub test {
    my $this = shift ;
    my $host = $this->{opts}->{H} ;
    my $port = $this->{opts}->{p} ;

    my $time = $this->now() ;
    my $ok = 0 ;
    # Test xxx @ $host:$port
    my $d = sprintf("%.3f", $this->now() - $time) ;
    if ($ok){
       $this->ok("XXX OK -  $d seconds response time") ;
    }
    else{
        $this->critical("XXX failed: <put your reason here>") ;
    }
}

my $p = new check_xxx() ;
$p->run() ;
-----------------------------------

So far it's worked well for me and it takes care of most of the repetitive
stuff
for writing a plugin. Once I'm done with it I'll submit it to CPAN.

Cheers,

Patrick

---------------------
Patrick LeBoutillier
Laval, Quebec, Canada
----- Original Message -----
From: "Stanley Hopcroft" <Stanley.Hopcroft at IPAustralia.Gov.AU>
To: <nagiosplug-devel at lists.sourceforge.net>
Cc: "'Subhendu Ghosh'" <sghosh at sghosh.org>;
<nagios-devel at lists.sourceforge.net>; <patrick_leboutillier at hotmail.com>
Sent: Wednesday, May 28, 2003 5:32 PM
Subject: Nagios::* namespace accepted on CPAN.


> Dear Ladies and Gentlemen,
>
> I am writing to say that CPAN has accepted the Nagios::* namespace for
> the use of Nagios related Perl modules.
>
> Potential occupants of this namespace could include :-
>
>  Nagios::utils.pm - an exporter module supplying subroutines and data
>                     structures, useful to those writing Nag service
>                     checks in Perl.
>
>  Nagios::NagConfig - Patrick LeBoutillier's class to read Nag config
>                      files (this is a suggested name for Patricks class)
>
>  Nagios::Web_Trx::* - classes that provide functions similar to but
>                      worse than WWW::Mechanize and WWW::Automate
>
>  ??? - other peoples classes that I cannot imagine which
>         . extend the Nagios core (exploiting the optional built-in Perl)
>         . extend the CGIs (or supplant them)
>         . do other wonderful things to extend Nags reach.
>
> Happy hacking.
>
> 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: eBay
Get office equipment for less on eBay!
http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5
_______________________________________________
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