Changeset 3415

Show
Ignore:
Timestamp:
03/13/10 12:21:55 (5 months ago)
Author:
steve.schnepp
Message:

stores the last_updated BDB in the same dir than datafile (dbdir)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/master/lib/Munin/Master/UpdateWorker.pm

    r3413 r3415  
    192192} 
    193193 
     194# Uses the standard Berkeley DB API available on the Perl install 
     195# It might be better to use the standard munin datafile, but it may not  
     196# scale to multiple parallel, and the access pattern is quite random. 
     197# So DB_File fits the bill here. So better have many small specialized files  
     198# in a KISS-oriented design. 
    194199sub is_fresh_enough { 
    195200        my ($nodedesignation, $service, $update_rate_in_seconds) = @_; 
     
    198203        DEBUG "is_fresh_enough asked for $key with a rate of $update_rate_in_seconds"; 
    199204 
     205        my $db_file = $config->{dbdir} . "/last_updated.db"; 
     206 
    200207        my %last_updated; 
    201         # XXX - ugly hack. Should be refactored to use a a common state provider 
    202208 
    203209        use Fcntl;   # For O_RDWR, O_CREAT, etc. 
    204210        use DB_File; 
    205         tie(%last_updated, 'DB_File', '/tmp/munin_plugins_last_updated', O_RDWR|O_CREAT, 0666) or ERROR "$!"; 
    206         my $last_updated_key = $last_updated{$key} || ""; 
     211        tie(%last_updated, 'DB_File', $db_file, O_RDWR|O_CREAT, 0666) or ERROR "$!"; 
     212 
     213        my $last_updated_key = $last_updated{$key} || "0 0"; 
    207214        DEBUG "last_updated{$key}: " . $last_updated_key; 
    208215        my @last = split(/ /, $last_updated_key); 
     
    213220        my $age = tv_interval(\@last, $now);     
    214221        DEBUG "last: " . Dumper(\@last) . ", now: " . Dumper($now) . ", age: $age"; 
    215         my $is_fresh_enough = ($age < $update_rate_in_seconds)
     222        my $is_fresh_enough = ($age < $update_rate_in_seconds) ? 1 : 0
    216223        DEBUG "is_fresh_enough  $is_fresh_enough"; 
    217224