diff options
author | Niko Tyni <ntyni@iki.fi> | 2007-10-27 14:05:57 +0200 |
---|---|---|
committer | Niko Tyni <ntyni@iki.fi> | 2007-10-27 14:05:57 +0200 |
commit | 51243891b9e493882c59e582c5188f48e1127bed (patch) | |
tree | c7c0b4d1ca1686f13d3ebb71b050d5c4e9155f23 /lib | |
parent | 15ce7b9d28dda1afb6b892c1e2a34e057f3fdb60 (diff) | |
download | smokeping-51243891b9e493882c59e582c5188f48e1127bed.tar.gz smokeping-51243891b9e493882c59e582c5188f48e1127bed.tar.xz |
count the rounds when pinging, needed for smarter logging
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Smokeping/probes/FPing.pm | 4 | ||||
-rw-r--r-- | lib/Smokeping/probes/base.pm | 14 | ||||
-rw-r--r-- | lib/Smokeping/probes/basefork.pm | 3 |
3 files changed, 20 insertions, 1 deletions
diff --git a/lib/Smokeping/probes/FPing.pm b/lib/Smokeping/probes/FPing.pm index 32e0735..c6cb9bc 100644 --- a/lib/Smokeping/probes/FPing.pm +++ b/lib/Smokeping/probes/FPing.pm @@ -100,6 +100,10 @@ sub testhost { sub ping ($){ my $self = shift; # do NOT call superclass ... the ping method MUST be overwriten + + # increment the internal 'rounds' counter + $self->increment_rounds_count; + my %upd; my $inh = gensym; my $outh = gensym; diff --git a/lib/Smokeping/probes/base.pm b/lib/Smokeping/probes/base.pm index 7747b77..15cd03e 100644 --- a/lib/Smokeping/probes/base.pm +++ b/lib/Smokeping/probes/base.pm @@ -64,7 +64,7 @@ sub new($$) my $class = ref($this) || $this; my $self = { properties => shift, cfg => shift, name => shift, - targets => {}, rtts => {}, addrlookup => {}}; + targets => {}, rtts => {}, addrlookup => {}, rounds_count => 0}; bless $self, $class; return $self; } @@ -94,6 +94,18 @@ sub ProbeUnit ($) { return "Seconds"; } +# this is a read-only variable that should get incremented by +# the ping() method +sub rounds_count ($) { + my $self = shift; + return $self->{rounds_count}; +} + +sub increment_rounds_count ($) { + my $self = shift; + $self->{rounds_count}++; +} + sub target2dynfile ($$) { # the targets are stored in the $self->{targets} # hash as filenames pointing to the RRD files diff --git a/lib/Smokeping/probes/basefork.pm b/lib/Smokeping/probes/basefork.pm index 4f50467..0de7b6d 100644 --- a/lib/Smokeping/probes/basefork.pm +++ b/lib/Smokeping/probes/basefork.pm @@ -146,6 +146,9 @@ DOC sub ping { my $self = shift; + # increment the internal 'rounds' counter + $self->increment_rounds_count; + my @targets = @{$self->targets}; return unless @targets; |