summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@iki.fi>2008-03-17 20:55:33 +0100
committerNiko Tyni <ntyni@iki.fi>2008-03-17 20:55:33 +0100
commit2fc87dbdce71a29396ad0236edc044f27596bdc0 (patch)
treed0240fd4bda86ee5dd0874647a253c59dfce8af4 /lib/Smokeping
parent1d4de6409ce490f5b33b2187372de7ea9c9ed307 (diff)
downloadsmokeping-2fc87dbdce71a29396ad0236edc044f27596bdc0.tar.gz
smokeping-2fc87dbdce71a29396ad0236edc044f27596bdc0.tar.xz
* store the slave updates in dyndir, defaulting to datadir --niko
Diffstat (limited to 'lib/Smokeping')
-rw-r--r--lib/Smokeping/Master.pm18
1 files changed, 17 insertions, 1 deletions
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 ){