summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping/probes/base.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Smokeping/probes/base.pm')
-rw-r--r--lib/Smokeping/probes/base.pm33
1 files changed, 26 insertions, 7 deletions
diff --git a/lib/Smokeping/probes/base.pm b/lib/Smokeping/probes/base.pm
index a322a21..c0525b6 100644
--- a/lib/Smokeping/probes/base.pm
+++ b/lib/Smokeping/probes/base.pm
@@ -90,6 +90,23 @@ sub ProbeDesc ($) {
return "Probe which does not overrivd the ProbeDesc methode";
}
+sub target2dynfile ($$) {
+ # the targets are stored in the $self->{targets}
+ # hash as filenames pointing to the RRD files
+ #
+ # now that we use a (optionally) different dir for the
+ # . adr files, we need to derive the .adr filename
+ # from the RRD filename with a simple substitution
+
+ my $self = shift;
+ my $target = shift; # filename with <datadir> embedded
+ my $dyndir = $self->{cfg}{General}{dyndir};
+ return $target unless defined $dyndir; # nothing to do
+ my $datadir = $self->{cfg}{General}{datadir};
+ $target =~ s/^\Q$datadir\E/$dyndir/;
+ return $target;
+}
+
sub rrdupdate_string($$)
{ my $self = shift;
my $tree = shift;
@@ -107,17 +124,18 @@ sub rrdupdate_string($$)
my $upperloss = $loss - $lowerloss;
@times = ((map {'U'} 1..$lowerloss),@times, (map {'U'} 1..$upperloss));
my $age;
- if ( -f $self->{targets}{$tree}.".adr" ) {
- $age = time - (stat($self->{targets}{$tree}.".adr"))[9];
+ my $dynbase = $self->target2dynfile($self->{targets}{$tree});
+ if ( -f $dynbase.".adr" ) {
+ $age = time - (stat($dynbase.".adr"))[9];
} else {
$age = 'U';
}
if ( $entries == 0 ){
$age = 'U';
$loss = 'U';
- if ( -f $self->{targets}{$tree}.".adr"
- and not -f $self->{targets}{$tree}.".snmp" ){
- unlink $self->{targets}{$tree}.".adr";
+ if ( -f $dynbase.".adr"
+ and not -f $dynbase.".snmp" ){
+ unlink $dynbase.".adr";
}
} ;
return "${age}:${loss}:${median}:".(join ":", @times);
@@ -131,12 +149,13 @@ sub addresses($)
foreach my $tree (keys %{$self->{targets}}){
my $target = $self->{targets}{$tree};
if ($target =~ m|/|) {
- if ( open D, "<$target.adr" ) {
+ my $dynbase = $self->target2dynfile($target);
+ if ( open D, "<$dynbase.adr" ) {
my $ip;
chomp($ip = <D>);
close D;
- if ( open D, "<$target.snmp" ) {
+ if ( open D, "<$dynbase.snmp" ) {
my $snmp = <D>;
chomp($snmp);
if ($snmp ne Smokeping::snmpget_ident $ip) {