Help me in finding logic


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Help me in finding logic
# 8  
Old 04-06-2009
Hi!

Well, you could try it yourself. Anyway, to get a spesific message you simply assign the message to the corresponding index of the array:
/Match_1/ { arr[$0] = "We got match_1" }

and in the END section:
for (f in arr) printf "%s\n", arr[f]

BR,

pen
# 9  
Old 04-06-2009
great reply pen.

I also thought a way after using my little brain. Could you please check this, i am working in both way to find out what is minimal resource usage scripts.

tail -n 2000 $TRACE | awk '
/TimeOutException/ { printf ("%s%s", "'"`email "TimeOutException" "$2"`"'")}

In our log file we get the time stamp at the second position.

and the function is

email()
{
echo "$1 occured at $2" | mail -s "Error!! $SERVER is thrown $1 - [$MYDATE]@[$MYTIME]" $mailid
}

waiting for your reply.

thanks
senthilkumar
# 10  
Old 04-07-2009
If the need is to be alerted whenever an exection is found in a log and many exeption need to be monitored I sugess you use WOTS.
It's a perl daemon that is made for that purpose. Alert doesn't have to be launch by cron anymore, you'll be alerted right away ...
you can find wots and learn more about it there:
Perl Tools for download

- Laurent
# 11  
Old 04-07-2009
Hi!

Forking every time a match has ben found is not really the answer... Anyway, I'd go on with Laurent's suggestion (thanks, Laurent!) and use a ready script. Sometimes it is better to use a ready wheel than re-invent one :-)

pen
# 12  
Old 04-07-2009
Hi Pen,

I tried to implement the Lauren way but failed as we cant install any perl package in the machine, so we need to go for shell script.

Also could you please let me know the calling email program inside the awk is correct logic, becuase i am getting alret even thou there is no error meesage and its not taking the second arugumnet "$2" value.

Thanks
senthilkumar
# 13  
Old 04-07-2009
Hi senthilkumar,

Which OS are you running ?
# 14  
Old 04-07-2009
senthilkumar,

The main problem I see using a tail is that if you had more then 2000 lines added to the log you will possibly miss an exception.

You could
Step 1- grep for the exception, output the result to a /tmp/search.0 file
Step 2 - if /tmp/search.old exist do a diff with /tmp/search.0 and mail the result
step 3 - renaim /tmp/search.0 /tmp/search.old

unless the log file is very large, (then you might rotate the log more often).

Still I think using wots would be better and you might find more usage to it, like alert you on software or hardware errors ...

- Laurent
 
Login or Register to Ask a Question

Previous Thread | Next Thread

1 More Discussions You Might Find Interesting

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
Login or Register to Ask a Question