Changeset 17281
- Timestamp:
- Apr 2, 2008, 12:02:03 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/arclog/arclog.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/arclog/arclog.pl
r17272 r17281 19 19 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 20 20 21 my $filter_records = 1;21 my $filter_records = 0; 22 22 23 23 my $rcfile = "$ENV{HOME}/.arclogrc"; … … 54 54 my $res = $ua->request(HTTP::Request->new(GET => "http://$hostport/")); 55 55 unless ($res->is_success) { 56 warn $res->status_line;56 warn "can't access $hostport: ", $res->status_line; 57 57 next; 58 58 } … … 71 71 $res= $ua->request($req); 72 72 unless ($res->is_success) { 73 die $res->status_line;73 die "can't access $hostport: ", $res->status_line; 74 74 } 75 75 … … 132 132 } 133 133 134 #use Data::Dumper;134 use Data::Dumper; 135 135 #print Dumper(\@records); 136 136 # sort by time 137 137 # insert all records 138 @records = sort { $a->{time} cmp $b->{time} } @records; 138 @records = sort { 139 unless (defined $a->{time} && defined $b->{time}) { 140 print Dumper($a); 141 print Dumper($b); 142 } 143 $a->{time} cmp $b->{time} 144 } @records; 139 145 my $query = $dbh->prepare("INSERT OR IGNORE INTO log VALUES(?)") 140 146 or die "database error: $!"; … … 155 161 156 162 # do not print filtered records 157 if ( defined$filter_records) {163 if ($filter_records) { 158 164 foreach my $filter (@myfilters) { 159 165 next RECORDS if $event =~ /$filter/; … … 191 197 @row_data{qw( time device event elapse_time errors )} = @fields; 192 198 199 # ipp008 has been returning valid rows with completely empty fields 200 return unless defined $row_data{time}; 201 193 202 # parse time string into a DateTime object for easy sorting later 194 $row_data{time} = $strptime->parse_datetime($row_data{time}); 203 my $dt = $strptime->parse_datetime($row_data{time}); 204 205 unless (defined $dt) { 206 # warn "can't parse time string $row_data{time}"; 207 return; 208 } 209 210 $row_data{time} = $dt; 195 211 196 212 return \%row_data;
Note:
See TracChangeset
for help on using the changeset viewer.
