IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17272


Ignore:
Timestamp:
Apr 2, 2008, 10:47:23 AM (18 years ago)
Author:
jhoblitt
Message:

figure out the last record seen PER host

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/arclog/arclog.pl

    r17271 r17272  
    1818# accept no options
    1919pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV;
     20
     21my $filter_records = 1;
    2022
    2123my $rcfile = "$ENV{HOME}/.arclogrc";
     
    98100# since the order in the sqllite db isn't guarenteed and we can't sort in the
    99101# db, we have to do this by hand
    100 my $last_recorded_time;
     102#
     103# futher, since it doesn't take 0 time to poll the cards -- and as it testing
     104# it was determined that some cards weren't properly synced to an NTP server.
     105# We should figure out the last record time for each host.
     106my %latest_times;
    101107{
    102108    my $strptime = DateTime::Format::Strptime->new(
     
    117123        my $dt = $strptime->parse_datetime($time);
    118124
    119         if (! defined $last_recorded_time) {
    120             $last_recorded_time = $dt;
    121         } elsif ($dt > $last_recorded_time) {
    122             $last_recorded_time = $dt;
     125        if (not exists $latest_times{$host}) {
     126            $latest_times{$host} = $dt;
     127        } elsif ($dt > $latest_times{$host}) {
     128            $latest_times{$host} = $dt;
    123129        }
    124130
    125     }
    126 
    127 #    warn "latest timestamp is: $last_recorded_time\n";
    128 
    129     unless (defined $last_recorded_time) {
    130         warn "failed to determine the time of the last recorded record\n";
    131131    }
    132132}
     
    150150    my ($host, $time, $device, $event, $elapse_time, $errors)
    151151        = @$rec{qw( host time device event elapse_time errors )};
     152    # pack record
    152153    $query->execute("$host|$time|$device|$event|$elapse_time|$errors")
    153154        or die "database error: $!";
    154155
    155156    # do not print filtered records
    156     foreach my $filter (@myfilters) {
    157         next RECORDS if $event =~ /$filter/;
     157    if (defined $filter_records) {
     158        foreach my $filter (@myfilters) {
     159            next RECORDS if $event =~ /$filter/;
     160        }
    158161    }
    159162   
    160     if ($time > $last_recorded_time) {
     163    if ($time > $latest_times{$host}) {
    161164        print "$host $time $device $event $elapse_time $errors\n";
    162165    }
Note: See TracChangeset for help on using the changeset viewer.