From 6d76521656e91daa160bc8019828f1b68d7aa5dc Mon Sep 17 00:00:00 2001 From: Niko Tyni Date: Sun, 13 Feb 2005 19:23:04 +0000 Subject: Moved probes, matchers and ciscoRttMonMIB modules to lib/Smokeping. --- lib/Smokeping/probes/skel.pm | 134 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 lib/Smokeping/probes/skel.pm (limited to 'lib/Smokeping/probes/skel.pm') diff --git a/lib/Smokeping/probes/skel.pm b/lib/Smokeping/probes/skel.pm new file mode 100644 index 0000000..fb7ade1 --- /dev/null +++ b/lib/Smokeping/probes/skel.pm @@ -0,0 +1,134 @@ +package Smokeping::probes::skel; + +=head1 301 Moved Permanently + +This is a Smokeping probe module. Please use the command + +C + +to view the documentation or the command + +C + +to generate the POD document. + +=cut + +use strict; +use base qw(Smokeping::probes::basefork); +# or, alternatively +# use base qw(Smokeping::probes::base); +use Carp; + +sub pod_hash { + return { + name => < < +document for more information. +DOC + authors => <<'DOC', + Niko Tyni , +DOC + see_also => < document +DOC + }; +} + +sub new($$$) +{ + my $proto = shift; + my $class = ref($proto) || $proto; + my $self = $class->SUPER::new(@_); + + # no need for this if we run as a cgi + unless ( $ENV{SERVER_SOFTWARE} ) { + # if you have to test the program output + # or something like that, do it here + # and bail out if necessary + }; + + return $self; +} + +# This is where you should declare your probe-specific variables. +# The example shows the common case of checking the availability of +# the specified binary. + +sub probevars { + my $class = shift; + return $class->_makevars($class->SUPER::probevars, { + #_mandatory => [ 'binary' ], + #binary => { + # _doc => "The location of your pingpong binary.", + # _example => '/usr/bin/pingpong', + # _sub => sub { + # my $val = shift; + # return "ERROR: pingpong 'binary' does not point to an executable" + # unless -f $val and -x _; + # return undef; + # }, + #}, + }); +} + +# Here's the place for target-specific variables + +sub targetvars { + my $class = shift; + return $class->_makevars($class->SUPER::targetvars, { + #weight => { _doc => "The weight of the pingpong ball in grams", + # _example => 15 + #}, + }); +} + +sub ProbeDesc($){ + my $self = shift; + return "pingpong points"; +} + +# this is where the actual stuff happens +# you can access the probe-specific variables +# via the $self->{properties} hash and the +# target-specific variables via $target->{vars} + +# If you based your class on 'Smokeping::probes::base', +# you'd have to provide a "ping" method instead +# of "pingone" + +sub pingone ($){ + my $self = shift; + my $target = shift; + + # my $binary = $self->{properties}{binary}; + # my $weight = $target->{vars}{weight} + # my $count = $self->pings($target); # the number of pings for this targets + + # ping one target + + # execute a command and parse its output + # you should return a sorted array of the measured latency times + # it could go something like this: + + my @times; + + #for (1..$count) { + # open(P, "$cmd 2>&1 |") or croak("fork: $!"); + # while (

) { + # /time: (\d+\.\d+)/ and push @times, $1; + # } + # close P; + #} + + + return @times; +} + +# That's all, folks! + +1; -- cgit v1.2.3-24-g4f1b