CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
Monitor Growing log Files for Exceptions

 



smart_amorist
Novice

Jan 23, 2009, 4:55 AM

Post #1 of 2 (799 views)
Monitor Growing log Files for Exceptions Can't Post

Hi All,

I am writing a code to monitor running processes and their log files. Suppose I have two Processes: Process_1 and Process_2, logs are Log_1 and Log_2. Everyday process, run it write to same log file. I want to run the program in loop. First run it should point to end of current log. It will finish its first run after looking for Log_1 and Log_2. In next run it (say sleeping for 5 mins) shoud only read the newly added lines in log Log_1 , Log_2 and check for exceptions. It should not read the log file from beginning during each cycle. I am trying something as below:

for (;;) {
for ($curpos = tell(FILE); $_ = <FILE>; $curpos = tell(FILE)) {
# search for some stuff and put it into files
}
sleep($for_a_while);
seek(FILE, $curpos, 0);
}


But it is not working. I am new to perl so not able to find much.

Please assist.


FishMonger
Veteran / Moderator

Jan 23, 2009, 5:36 AM

Post #2 of 2 (795 views)
Re: [smart_amorist] Monitor Growing log Files for Exceptions [In reply to] Can't Post

File::Monitor
http://search.cpan.org/~andya/File-Monitor-0.10/lib/File/Monitor.pm

File::Tail
http://search.cpan.org/~mgrabnar/File-Tail-0.99.3/Tail.pm

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives