Changeset 3415
- Timestamp:
- 03/13/10 12:21:55 (5 months ago)
- Files:
-
- trunk/master/lib/Munin/Master/UpdateWorker.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/master/lib/Munin/Master/UpdateWorker.pm
r3413 r3415 192 192 } 193 193 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. 194 199 sub is_fresh_enough { 195 200 my ($nodedesignation, $service, $update_rate_in_seconds) = @_; … … 198 203 DEBUG "is_fresh_enough asked for $key with a rate of $update_rate_in_seconds"; 199 204 205 my $db_file = $config->{dbdir} . "/last_updated.db"; 206 200 207 my %last_updated; 201 # XXX - ugly hack. Should be refactored to use a a common state provider202 208 203 209 use Fcntl; # For O_RDWR, O_CREAT, etc. 204 210 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"; 207 214 DEBUG "last_updated{$key}: " . $last_updated_key; 208 215 my @last = split(/ /, $last_updated_key); … … 213 220 my $age = tv_interval(\@last, $now); 214 221 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; 216 223 DEBUG "is_fresh_enough $is_fresh_enough"; 217 224
