Visit Our UNIX and Linux User Community


track the errors in log file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting track the errors in log file
# 1  
Old 05-21-2009
Question track the errors in log file

OS: SuSE Linux Enterprise Server 10

Goal:
To track the errors in log file, If they exits users will be notify by email.

We have a script below:
Code:
SrchKey="SRVE0242I:"
LogFile=/PATHtemOut.log
MailTo="DN@mail.com
http:// ! -f PATH/alert.last  && touch PATH/alert.last
egrep $SrchKey $LogFile > PATH/alert.new
if http:// -s PATH/alert.new  ;then
diff PATH/alert.new PATH/alert.last > PATH/alert.msg
cp PATH/alert.new PATH/alert.last
http:// -s PATH/alert.msg  &&
mailx -v -s "$SrchKey Alert" $MailTo < PATH/alert.msg
else
echo "Nothing to report, sir." | mailx -s "No Alert Today" ${MailTo}
fi

OUT PUT:

Received email
Subject:SRVE0242I: Alert

Message: "1d0
< Binary file /PATH/log/SystemOut.log matches"

1) We have multiple error messages,
how to add more messages in the script?

2) If one of the message does not exits we should receive message for other existing error code or messages.

thanks
D

Last edited by Franklin52; 05-22-2009 at 07:59 AM.. Reason: adding code tags
# 2  
Old 05-22-2009
Any feedback will be appreciated
# 3  
Old 05-23-2009
You will need to define the serach parameters/error code and repeat the same you already have. Try using the extended RE.

example:

Code:
egrep "one|two|three" filename > msg

[ will grep for the strings one or two or three etc]
# 4  
Old 06-02-2009
so code will be as below:




SrchKey="SRVE0242I:| error| hang"
LogFile=/PATHtemOut.log
MailTo="DN@mail.com
http:// ! -f PATH/alert.last && touch PATH/alert.last
egrep $SrchKey $LogFile > PATH/alert.new
if http:// -s PATH/alert.new ;then
diff PATH/alert.new PATH/alert.last > PATH/alert.msg
cp PATH/alert.new PATH/alert.last
http:// -s PATH/alert.msg &&
mailx -v -s "$SrchKey Alert" $MailTo < PATH/alert.msg
else
echo "Nothing to report, sir." | mailx -s "No Alert Today" ${MailTo}
fi

Previous Thread | Next Thread
Test Your Knowledge in Computers #26
Difficulty: Easy
IPv6 addresses are 256 bits in length.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Outputting Errors to a Log file

Good Morning, Every so often, I have copy scripts that to don't complete, but I don't immediately know why. It usually ends up being a permissions issue or a length issue. The scripts edit a log file, so I'd like to include any copy errors/issues in that file to check if the copies... (4 Replies)
Discussion started by: Stellaman1977
4 Replies

2. UNIX for Beginners Questions & Answers

Need in for a script that should check for errors in multiple log file (approx 2500) and should mail

hello everyone, I am new to linux and got this deliverable to write a script that should check for error in multiple log file (count is approx 2500 log files on single server) and once error is found, it should mail that error My logic says: we can put all log files path/location in one... (2 Replies)
Discussion started by: Pratik_CTS
2 Replies

3. Shell Programming and Scripting

Scan log file for errors

Hi everyone. I am still new to UNIX, and am having trouble figuring out how to create a script to scan a log file to look for errors based on a string. We run AIX 5.3, and would like the ability to report all the instances of WebSphere Broker Execution groups crashing. This script would... (8 Replies)
Discussion started by: jimbojames
8 Replies

4. Shell Programming and Scripting

Finding errors in log file only in last 10 minutes

Hi there, I have a log file that I need to check every 10 minutes to find if a specific error exists but only in that 10 minute period. The reason is that the log is quite large, and will frequently contain these errors, so I only want alerting if it in the last 10 minutes - I don't want... (3 Replies)
Discussion started by: paul_vf
3 Replies

5. Shell Programming and Scripting

Capturing errors messages into log file

Can we capture and write all the error messages which were being displayed on the command prompt screen during execution of a program into a log file? If yes, can anyone please let me know on how to do it? I am using ksh and working on AIX server. Thank you in advance. (4 Replies)
Discussion started by: vpv0002
4 Replies

6. Homework & Coursework Questions

Track user log!

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: The task is to measure the density of users that are logged on system. The program should check that every 30... (7 Replies)
Discussion started by: petel1
7 Replies

7. Shell Programming and Scripting

how to track a log file of one process and mail that logfile to a group?

Hi Friendz, I have 14 DB load scripts say 1,2,3....14. I want a script to call each script automatically, and after completion of every script, it needs to track the logfile and mail that log file to a group.and again it should run the next script in sequence 1,2,3...14 Please help me,need... (1 Reply)
Discussion started by: shirdi
1 Replies

8. Shell Programming and Scripting

prevent errors/warnings from being written to log file

i have this script which works fine but shows errors when it runs..these are more like warnings and the script runs fine.. i am on a sun machine.. i know it writes all the error messages to a master log file.. is there any way i can turn off these warnings/error messages and prevent them from being... (2 Replies)
Discussion started by: npatwardhan
2 Replies

9. Shell Programming and Scripting

redirect errors to log file

I am working on a generic script that will run a shell script with the arguments passed and redirect errors to one file, and all other output to another file. Then if there is anything in the error file it emails the error to me, otherwise it exits. The advantage for this approach is that I... (0 Replies)
Discussion started by: gandolf989
0 Replies

10. UNIX for Dummies Questions & Answers

Possible to track FTP user last login? Last and Finger don't track them.

Like the topic says, does anyone know if it is possible to check to see when an FTP only user has logged in? Because the shell is /bin/false and they are only using FTP to access the system doing a "finger" or "last" it says they have never logged in. Is there a way to see when ftp users log in... (1 Reply)
Discussion started by: LordJezo
1 Replies

Featured Tech Videos