Changeset 17271
- Timestamp:
- Apr 1, 2008, 4:10:55 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/arclog/arclog.pl (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/arclog/arclog.pl
r17269 r17271 95 95 } 96 96 97 # figure out the last record that we saw 98 # since the order in the sqllite db isn't guarenteed and we can't sort in the 99 # db, we have to do this by hand 100 my $last_recorded_time; 101 { 102 my $strptime = DateTime::Format::Strptime->new( 103 pattern => '%Y-%m-%dT%H:%M:%S' 104 ); 105 106 # read in the entire database 107 my $query = $dbh->prepare("SELECT * FROM log") 108 or die "database error: $!"; 109 $query->execute or die "database error: $!"; 110 my $records = $query->fetchall_arrayref; 111 112 # sort it for the latest timestamp 113 foreach my $rec (@$records) { 114 my ($host, $time, $device, $event, $elapse_time, $errors) 115 = split(/\|/, $rec->[0]); 116 117 my $dt = $strptime->parse_datetime($time); 118 119 if (! defined $last_recorded_time) { 120 $last_recorded_time = $dt; 121 } elsif ($dt > $last_recorded_time) { 122 $last_recorded_time = $dt; 123 } 124 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"; 131 } 132 } 133 97 134 #use Data::Dumper; 98 135 #print Dumper(\@records); … … 120 157 next RECORDS if $event =~ /$filter/; 121 158 } 122 print "$host $time $device $event $elapse_time $errors\n"; 159 160 if ($time > $last_recorded_time) { 161 print "$host $time $device $event $elapse_time $errors\n"; 162 } 123 163 124 164 use warnings;
Note:
See TracChangeset
for help on using the changeset viewer.
