monitor log files

Hello,

I want something like this

tail -f /a/b/c/*.log | grep -i "STRING1|STRING2 " > a.txt

I want to check all the log files in a particular directory then grep if any of the log files have "STRING1" and "STRING2" string and then have to send email to the group.

Platform is HP-UX

it can be a shell or perl script.

Thanks in advance.

Hello,

is uxtail available at your HP-UX system?

uxtail ?

/opt/uxt/.....

From swlist:
uxt -> 2.1 uxt

Regards

Regards

no it is not being installed.....

Maybe you can use logmon?

The Wandering Geek : /monitoring-and-alerting-on-linux-logfiles.html

or logwatch?

I have already seen this but no success.....:frowning: :frowning: is there any other way to do the same?

Your proposed script will only look at the first file matching the pattern /a/b/c/*.log .

Are you trying to monitor these logs in real time?

How many different logs are involved?

How large are these logs? Kilobytes, Megabytes, Gigabytes?

What is an acceptable delay between the error message "STRING1" or "STRING2" appearing in a log and the error email being sent?

My usual approach is to set up a cron job to examine a log at fixed time intervals to record events and report any new events.

The code snippet is just; what i am looking for. It is not a working piece because i am not able to redirect the grep thing into a file.

1) I want to search for both the string "STRING1" and "STRING2". If any of the strings is present in any of the logs immediately it should send an e-mail.

2) There will be approximately 60 log files.

3) Log files will be of size 2 MB approx.

4) Error message depends upon some application failure.

5) Yes, if script is done then I can run it in cron job.

Regards,
RTY

very simply...

TMPFILE=/tmp/blah.log
tail -f /a/b/c/*.log | grep -i "STRING1|STRING2 " > $TMPFILE
[ -s "$TMPFILE" ] || exit      # file is zero size => exit
mailx -s 'got errors' user@host < $TMPFILE

I am not able to redirect the grep output in a file. Can we do that I doubt !!

Please confirm.

Regards,
RTY