From 2fc87dbdce71a29396ad0236edc044f27596bdc0 Mon Sep 17 00:00:00 2001 From: Niko Tyni Date: Mon, 17 Mar 2008 19:55:33 +0000 Subject: * store the slave updates in dyndir, defaulting to datadir --niko --- lib/Smokeping/Master.pm | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'lib/Smokeping/Master.pm') diff --git a/lib/Smokeping/Master.pm b/lib/Smokeping/Master.pm index f910c09..81ce01f 100644 --- a/lib/Smokeping/Master.pm +++ b/lib/Smokeping/Master.pm @@ -89,8 +89,18 @@ database by the rrd daemon as the next round of updates is processed. This two stage process is chosen so that all results flow through the same code path in the daemon. +The updates are stored in the directory configured as 'dyndir' in the 'General' +configuration section, defaulting to the value of 'datadir' from the same section +if 'dyndir' is not present. + =cut +sub slavedatadir ($) { + my $cfg = shift; + return $cfg->{General}{dyndir} || + $cfg->{General}{datadir}; +} + sub save_updates { my $cfg = shift; my $slave = shift; @@ -100,7 +110,7 @@ sub save_updates { for my $update (split /\n/, $updates){ my ($name, $time, $updatestring) = split /\t/, $update; - my $file = $cfg->{General}{datadir}."/${name}.${slave}.slave_cache"; + my $file = slavedatadir($cfg) ."/${name}.${slave}.slave_cache"; if ( ${name} =~ m{(^|/)\.\.($|/)} ){ warn "Skipping update for ${name}.${slave}.slave_cache since ". "you seem to try todo some directory magic here. Don't!"; @@ -144,11 +154,17 @@ Read in all updates provided by the selected slave and return an array reference =cut sub get_slaveupdates { + my $cfg = shift; my $name = shift; my $slave = shift; my $file = $name . "." . $slave. ".slave_cache"; my $empty = []; my $data; + + my $datadir = $cfg->{General}{datadir}; + my $dir = slavedatadir($cfg); + $file =~ s/^\Q$datadir\E/$dir/; + my $fh; if ( open ($fh, '<', $file) ) { if ( flock $fh, LOCK_SH ){ -- cgit v1.2.3-24-g4f1b