Sponsored Content
Full Discussion: Help me in finding logic
Top Forums UNIX for Dummies Questions & Answers Help me in finding logic Post 302304508 by senthilkumar_ak on Monday 6th of April 2009 03:45:30 PM
Old 04-06-2009
Bug Help me in finding logic

I am searching for some logic which will help me to introduce quick action for the errors. We have application server and we need to check the bunch of information for every 10 minutes and alert thru mail. I wrote a script in which i am tailing last 1000 lines and counting one exception then sending mail like below

count=`tail -n 2000 /logsTrace.log | grep -c 'TimeOutException'`
if [ $count -ne 0 ]
then
echo "Error! $server is thrown TimeOutException $(date +"%D %T")" >> temp.txt
cat temp.txt | mail -s "Error! $server is thrown TimeOutException $(date +"%D %T")" $mail_id

i need to change my logic with the awk command where i can take like this for all exception tailing at one time

tail -n 1000 /logs/Trace.log | awk 'BEGIN{Jms = 0; OOM = 0}
/TimeOutException/{Jms++}
/OutOfMemoryException/{OOM = 1}
END{printf "%-10s%-10s",Jms,OOM;}'

like wise i can add for all the exception by tailing one time the log so that i can minimize the use of tailing. But how do i can send mail. Is there any way to do this please help me. i am stuck in that.

Thanks
Senthilkumar AK
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

finding duplicate files by size and finding pattern matching and its count

Hi, I have a challenging task,in which i have to find the duplicate files by its name and size,then i need to take anyone of the file.Then i need to open the file and find for more than one pattern and count of that pattern. Note:These are the samples of two files,but i can have more... (2 Replies)
Discussion started by: jerome Sukumar
2 Replies
WRITELOG(8)						      System Manager's Manual						       WRITELOG(8)

NAME
writelog - add a entry to an INN log file. SYNOPSIS
writelog name text... DESCRIPTION
The writelog script is used to write a log entry or send it as mail. The name parameter specifies the name of the log file where the entry should be written. If it is the word ``mail'' then the entry is mailed to the news administrator, <USER specified with --with-news-mas- ter at configure>. The data that is written or sent consists of the text given on the command line, followed by standard input indented by four spaces. Shlock(1) is used to avoid simultaneous updates to a single log file. HISTORY
Written by Landon Curt Noll <chongo@toad.com> and Rich $alz <rsalz@uunet.uu.net> for InterNetNews. This is revision 5909, dated 2002-12-03. SEE ALSO
innd(8), innstat(8), news.daily(8), newslog(5), nnrpd(8), scanlogs(8). WRITELOG(8)
All times are GMT -4. The time now is 10:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy