summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--lib/Smokeping.pm6
-rw-r--r--lib/Smokeping/Master.pm18
3 files changed, 23 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index 79a8e80..07f30b7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+* store the slave updates in 'dyndir', defaulting to 'datadir' --niko
+
* change the slave update locking code so that reading works without
write access to the temporary storage file --niko
diff --git a/lib/Smokeping.pm b/lib/Smokeping.pm
index 6f30120..71e64d4 100644
--- a/lib/Smokeping.pm
+++ b/lib/Smokeping.pm
@@ -1859,7 +1859,7 @@ sub update_rrds($$$$$$) {
if ($tree->{slaves}){
my @slaves = split(/\s+/, $tree->{slaves});
foreach my $slave (@slaves) {
- my $lines = Smokeping::Master::get_slaveupdates($name, $slave);
+ my $lines = Smokeping::Master::get_slaveupdates($cfg, $name, $slave);
push @updates, @$lines;
} #foreach my $checkslave
}
@@ -2488,7 +2488,9 @@ DOC
%$DIRCHECK_SUB,
_doc => <<DOC,
The base directory where SmokePing keeps the files related to the DYNAMIC function.
-This directory must be writeable by the WWW server.
+This directory must be writeable by the WWW server. It is also used for temporary
+storage of slave polling results by the master in
+L<the master/slave mode|smokeping_master_slave>.
If this variable is not specified, the value of C<datadir> will be used instead.
DOC
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 ){