log monitoring


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers log monitoring
# 1  
Old 01-14-2003
Question log monitoring

Hi there,

I have an application runnig on HP_UX which logs critical mesages to a log file.

What I would like to do is tail the log file and report on new messages. Easy....I here you say.

The log file is continuing to be written to and the check scritp will be executed from cron. I was thinking on having a file with the last wc -l stored in it and then having a variable that is the current wc -l of the log file.

How could I subtract the original wc from the stored wc to use in the tail -x? these would be only the new messages.

(orig wc) - (new wc) = tail -n lines

Do you know what I mean? From these new lines I will report and audit..

Cheers in advance all you lucky people.Smilie
# 2  
Old 01-14-2003
You may want to use sed instead of tail. You would have to keep the wc -l from the first run somewhere external to the script, probably in a small file. Then you could do something like this:

orig_wc=`cat file_with_line_count.txt`
new_wc=`wc -l log_file`
sed -n "$orig_wc,$new_wc p" |grep ERROR or whatever

You may have to play with the sed syntax but it should be close (doing it from memory).
# 3  
Old 01-15-2003
How often do you want to run the script.
I've used a script that runs at 23:55 of every day and reports an email of the days errors to those onsite (24x7 operation).

If they need to action anything straight away they call, otherwise the Sys Admin's check it out when they come in (also included in the email distribution).
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Monitoring script for Log file

Hi, Iam new to unix , plz help me to write below script. I need to write a script for Monitoring log file when any error occurs it has to send a mail to specified users and it should be always pick latest error not the existing one and the script should be able to send mail all errors (more... (1 Reply)
Discussion started by: vij05
1 Replies

2. Shell Programming and Scripting

Monitoring script for a log file

Hi, I need to get a script working to monitor a log file and throw an alert via mailx as soon as a particular error is encountered. I do not want repeatative email notifications of same error so simply cat logfile and grepping the error would not work. Here is what i planned but it seems... (2 Replies)
Discussion started by: roshan.171188
2 Replies

3. Shell Programming and Scripting

Monitoring log for FATAL in last 15mins only

Hi all, I need to develop the following script. Could anyone please provide me some inputs. 1) Monitor the system log file (sys.log) for any lines in the parameter file that will contain all the different phrases of FATAL errors that the process has to scan for in the sys.log. If any FATAL... (7 Replies)
Discussion started by: stunnerz_84
7 Replies

4. Shell Programming and Scripting

Online log monitoring script

#!/bin/bash tail /oracle/app/admin/ABC/bdump/alert_ABC.log >> tempoutput& Error=`egrep 'error|warn|critical|fail|ORA-1683' tempoutput` echo "$Error" |mailx -s "ABC Error " ABCD@domain.lk cat /dev/null > tempoutput I wrote this script and put in to cronjob every 5 min. so every 5... (4 Replies)
Discussion started by: hishanms
4 Replies

5. Shell Programming and Scripting

Monitoring a users log in time?

how do i start with this guys? Sample run: $ LOGTIME it2015678 <enter> User it2015678 is CRUZ Tommy H And has logged on to the system for: 8 hours 12 minutes from the time this script was run. (1 Reply)
Discussion started by: skypigeon
1 Replies

6. Shell Programming and Scripting

log monitoring

Hi All; I have a log file(dynamic) which i need to monitor; the format of the log file is as follows #Session ID STATUS The status can be one of the three /starting ;/loading ;/success Example #Session ID STATUS ABC /started.html XYZ /started.html ABC /loading.html ABC... (2 Replies)
Discussion started by: maverick_here
2 Replies

7. Shell Programming and Scripting

Automate Log Monitoring Process

I am a new member of this forum and am also new to unix shell scripting. I joined the forum to seek for help to achieve my task as this forum helps people. here's what i do manually on daily basis 1)Loginto different unix box 2)Ftp the log files (morethan 50 each dir) to windows 3)use text pad... (3 Replies)
Discussion started by: sharugan
3 Replies

8. Shell Programming and Scripting

Monitoring log file

Hi, I ned to monitor the tomcat log file called "catalina.out" for "Out of memory" error. the script should monitor this file and send us the mail as soon as it finds the string "Out of memory" in the file. can ypu suggest me which is the best way to do this? (4 Replies)
Discussion started by: shivanete
4 Replies

9. Windows & DOS: Issues & Discussions

Log monitoring in windows

Hi, I'd like to know if there is a way to monitor a log file conitnuously for one or more strings and if found, send an alarm. It should also take care not to inlcude the old log file entries. Thanks. (2 Replies)
Discussion started by: er_ashu
2 Replies

10. Shell Programming and Scripting

Log Monitoring through Perl

Hi, I am new to perl. I want to write a perl script to monitor logs. Where i want to monitor exceptions logged or any kind of error strings. I have a dir(On Solaris) with multiple log file which keeps rolling to .gz file after some time in that same dir. These logs files size keeps on... (0 Replies)
Discussion started by: solitare123
0 Replies
Login or Register to Ask a Question