summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping/probes/basevars.pm
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2005-02-13 20:23:04 +0100
committerNiko Tyni <ntyni@iki.fi>2005-02-13 20:23:04 +0100
commit6d76521656e91daa160bc8019828f1b68d7aa5dc (patch)
treeaaa27615a0702942fa1606d9a5c89f0a3547467c /lib/Smokeping/probes/basevars.pm
parent6dba1afbe4b475a7d34f5ef867b7b37291cd1484 (diff)
downloadsmokeping-6d76521656e91daa160bc8019828f1b68d7aa5dc.tar.gz
smokeping-6d76521656e91daa160bc8019828f1b68d7aa5dc.tar.xz
Moved probes, matchers and ciscoRttMonMIB modules to lib/Smokeping.
Diffstat (limited to 'lib/Smokeping/probes/basevars.pm')
-rw-r--r--lib/Smokeping/probes/basevars.pm102
1 files changed, 102 insertions, 0 deletions
diff --git a/lib/Smokeping/probes/basevars.pm b/lib/Smokeping/probes/basevars.pm
new file mode 100644
index 0000000..26c0d85
--- /dev/null
+++ b/lib/Smokeping/probes/basevars.pm
@@ -0,0 +1,102 @@
+package Smokeping::probes::basevars;
+
+=head1 301 Moved Permanently
+
+This is a Smokeping probe module. Please use the command
+
+C<smokeping -man Smokeping::probes::basevars>
+
+to view the documentation or the command
+
+C<smokeping -makepod Smokeping::probes::basevars>
+
+to generate the POD document.
+
+=cut
+
+use strict;
+use Smokeping::probes::base;
+use base qw(Smokeping::probes::base);
+
+my $e = "=";
+sub pod_hash {
+ return {
+ name => <<DOC,
+Smokeping::probes::basevars - Another Base Class for implementing SmokePing Probes
+DOC
+ overview => <<DOC,
+Like Smokeping::probes::base, but supports host-specific variables for the probe.
+DOC
+ description => <<DOC,
+Provides the method `targets' that returns a list of hashes.
+The hashes contain the entries:
+
+${e}over
+
+${e}item addr
+
+The address of the target.
+
+${e}item vars
+
+A hash containing variables defined in the corresponding
+config section.
+
+${e}item tree
+
+The unique index that `probe::base' uses for targets.
+
+There's also the method 'vars' that returns the abovementioned
+hash corresponding to the 'tree' index parameter.
+
+${e}back
+DOC
+ authors => <<'DOC',
+Niko Tyni <ntyni@iki.fi>
+DOC
+ bugs => <<DOC,
+Uses `Smokeping::probes::base' internals too much to be a derived class, but
+I didn't want to touch the base class directly.
+DOC
+ see_also => <<DOC,
+Smokeping::probes::base(3pm), Smokeping::probes::EchoPing(3pm)
+DOC
+ }
+}
+
+sub add($$)
+{
+ my $self = shift;
+ my $tree = shift;
+
+ $self->{targets}{$tree} = shift;
+ $self->{vars}{$tree} = { %{$self->{properties}}, %$tree };
+}
+
+sub targets {
+ my $self = shift;
+ my $addr = $self->addresses;
+ my @targets;
+
+ # copy the addrlookup lists to safely pop
+ my %copy;
+
+ for (@$addr) {
+ @{$copy{$_}} = @{$self->{addrlookup}{$_}} unless exists $copy{$_};
+ my $tree = pop @{$copy{$_}};
+ push @targets, { addr => $_, vars => $self->{vars}{$tree}, tree => $tree };
+ }
+ return \@targets;
+}
+
+sub vars {
+ my $self = shift;
+ my $tree = shift;
+ return $self->{vars}{$tree};
+}
+
+sub ProbeDesc {
+ return "Probe that supports variables and doesn't override the ProbeDesc method";
+}
+
+return 1;