Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
The logic is that you are testing the log file for a specific condition. You create a starting condition that assumes that everything has gone well and would result in a green button. The idea is that if you get to the end of the file without hitting one of your two tests then everything was OK.

You read the file one line at a time looking for either DOWN or PROBLEM. When one of these tests work, you set the button response accordingly and use last to leave the while loop and do something with the outcome.

You may only be reading 5Mb of files but this translates into a much larger use of memory. It also involves the computer reading the file line by line anyway as it puts it into memory. If your match is on line 20 of a 2000 line file, your script only needs to read 20 lines and you are done.

If you continue to have trouble, post your code in the replies.


In reply to Re^3: trouble parsing log file... by inman
in thread trouble parsing log file... by perl_geoff

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2024-04-23 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found