summaryrefslogtreecommitdiffstats
path: root/lib/Smokeping
diff options
context:
space:
mode:
authorTobi Oetiker <tobi@oetiker.ch>2008-01-21 23:18:48 +0100
committerTobi Oetiker <tobi@oetiker.ch>2008-01-21 23:18:48 +0100
commit88c73fdb0c653f6366a06c21aa9c055245b8641a (patch)
tree84e9c0fe88aa94a291e43831bd4bd603a84e8acc /lib/Smokeping
parentf0d944ab93f7603843ba3a8ec825261d339c7eef (diff)
downloadsmokeping-88c73fdb0c653f6366a06c21aa9c055245b8641a.tar.gz
smokeping-88c73fdb0c653f6366a06c21aa9c055245b8641a.tar.xz
added alternate presentation hierarchies. Configure via Presentation->hierarchies and
Targets ... -> parents -- tobi
Diffstat (limited to 'lib/Smokeping')
-rw-r--r--lib/Smokeping/Graphs.pm7
-rw-r--r--lib/Smokeping/Master.pm39
2 files changed, 23 insertions, 23 deletions
diff --git a/lib/Smokeping/Graphs.pm b/lib/Smokeping/Graphs.pm
index 284ab33..2a2894b 100644
--- a/lib/Smokeping/Graphs.pm
+++ b/lib/Smokeping/Graphs.pm
@@ -34,9 +34,13 @@ sub get_multi_detail ($$$$;$){
my $tree = shift;
my $open = shift;
my $mode = shift || $q->param('displaymode') || 's';
+ my $open_phys = $open;
+ if ($tree->{__real_path}){
+ $open_phys = $tree->{__real_path};
+ }
- my @dirs = @{$open};
+ my @dirs = @{$open_phys};
return "<div>ERROR: ".(join ".", @dirs)." has no probe defined</div>"
unless $tree->{probe};
@@ -291,6 +295,7 @@ sub get_multi_detail ($$$$;$){
. $q->hidden(-name=>'epoch_start',-id=>'epoch_start',-default=>$start)
. $q->hidden(-name=>'epoch_end',-id=>'epoch_end',-default=>time())
. $q->hidden(-name=>'target',-id=>'target' )
+ . $q->hidden(-name=>'hierarchy',-id=>'hierarchy' )
. $q->hidden(-name=>'displaymode',-default=>$mode )
. "&nbsp;"
. $q->submit(-name=>'Generate!')
diff --git a/lib/Smokeping/Master.pm b/lib/Smokeping/Master.pm
index e54a264..4a5cd90 100644
--- a/lib/Smokeping/Master.pm
+++ b/lib/Smokeping/Master.pm
@@ -1,7 +1,7 @@
# -*- perl -*-
package Smokeping::Master;
use Data::Dumper;
-use Storable qw(nstore_fd dclone fd_retrieve);
+use Storable qw(nstore dclone retrieve);
use strict;
use warnings;
use Fcntl qw(:flock);
@@ -105,30 +105,27 @@ sub save_updates {
" in the local data structure. Make sure you run the ".
"smokeping daemon. ($cfg->{General}{datadir})\n";
}
- elsif ( open (my $hand, '+>>' , $file) ) {
- for (my $i = 10; $i < 0; $i--){
- if ( flock $hand, LOCK_EX ){
+ elsif ( open (my $lock, '>>' , "$file.lock") ) {
+ for (my $i = 10; $i > 0; $i--){
+ if ( flock $lock, LOCK_EX ){
my $existing = [];
- if ( (stat($hand))[7] > 0 ){
- seek $hand, 0,0;
- eval { $existing = fd_retrieve $hand };
+ if ( -r $file ){
+ my $in = eval { retrieve $file };
if ($@) { #error
warn "Loading $file: $@";
- $existing = [];
- }
+ } else {
+ $existing = $in;
+ };
};
push @{$existing}, [ $slave, $time, $updatestring];
- seek $hand, 0,0;
- truncate $hand, 0;
- nstore_fd ($existing, $hand);
- flock $hand, LOCK_UN;
+ nstore($existing, $file);
last;
} else {
warn "Could not lock $file. Trying again for $i rounds.\n";
sleep rand(3);
}
}
- close $hand;
+ close $lock;
} else {
warn "Could not update $file: $!";
}
@@ -145,20 +142,18 @@ sub get_slaveupdates {
my $name = shift;
my $file = $name.".slave_cache";
my $data;
- if ( open (my $hand, '+<', $file) ) {
- if ( flock $hand, LOCK_EX ){
- rename $file,$file.$$;
- eval { $data = fd_retrieve $hand };
- unlink $file.$$;
- flock $hand, LOCK_UN;
+ if ( -r $file and open (my $lock, '>>', "$file.lock") ) {
+ if ( flock $lock, LOCK_EX ){
+ eval { $data = retrieve $file };
+ unlink $file;
if ($@) { #error
warn "Loading $file: $@";
- return;
+ return undef;
}
} else {
warn "Could not lock $file. Will skip and try again in the next round. No harm done!\n";
}
- close $hand;
+ close $lock;
return $data;
}
return;