Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Logfile checking

by Generoso (Parson)
on Aug 16, 2010 at 20:59 UTC ( #855359=note: print w/replies, xml ) Need Help??

in reply to Logfile checking

Can you provide sample data of the files that you are comparing. This will help us understand better what you are trying to do.

Replies are listed 'Best First'.
Re^2: Logfile checking
by pramone (Initiate) on Aug 16, 2010 at 21:27 UTC
    I have created test logfiles that just have random messages with one or two that match the string in the config file. Currently I have a test config file that looks like such:
    #format is:- # # #time_start:time_end:day_start:day_end:drive:path:filename:error messages have been receiv +ed from the remote host for the specified time period.
    So the logfile has random strings and then a string that matches above.

      Barebones approach that you can extrapolate into what you're looking for:

      #!/usr/bin/perl -w use strict; open my $config, "config.cfg" or die "config.cfg: $!\n"; # Assuming the config file structure is one error per line my %errlist = map { chomp; $_ => 1 } <$config>; close $config; open my $log, "logfile.txt" or die "logfile.txt: $!\n"; while (<$log>){ chomp; /:([^:]+)$/; print "Error '$1' found on line $.\n" if exists $errlist{$1}; }

      In other words, you use the hash to store all your "valid errors", then check the actual errors against that hash. Fairly common algorithm, certainly in Perl.

      "Language shapes the way we think, and determines what we can think about."
      -- B. L. Whorf

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://855359]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-03-18 21:59 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (231 votes). Check out past polls.