Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Logfile checking

by Generoso (Vicar)
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.


Comment on Re: Logfile checking
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 0000:2300:1:5:C:Temp:test.server.net.log:No 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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://855359]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2014-12-18 09:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (48 votes), past polls