Monday, July 25, 2011

How to extract exception stack trace from javaEE application log file ?

I had the requirement to extract complete list of exception stack trace from java EE application log files for past 6 months and analyze the root cause for all exceptions.

I used the following sed commands to get the list which has all duplicate list of exceptions.

sed -ne '/ERROR/,/WebContainer :/p' *.log.2011* >/tmp/exception_list.txt
sed -i '/WARN/d' /tmp/exception_list.txt
sed -i '/INFO/d' /tmp/exception_list.txt
sed '/com.ibm.ws/d' -e '/org.apache/d' /tmp/exception_list.txt
sed -e '/com.ibm.ws/d' -e '/org.apache/d' /tmp/exception_list.txt


Remove duplicate exception block from the log.

1) Remove time/date information from log entry cut -f 2 -d']'
exception_list.txt
2)Remove additional spaces if any sed 's/ ERROR/ERROR/'
/tmp/exception_list.txt

uniq
command will not work unless is sorted (sort), so use below command to remove duplicates with out changing line order

awk ' !x[$0]++'
/tmp/exception_list.txt >/tmp/exception_list_final.txt


Wednesday, July 20, 2011

How to delete duplicate MS communicator conversation copied to outlook History folder ?

Recently I faced below problem and couldn't find any solution/tools in internet. I decided to solve the problem myself.

I have enabled the option to save MS communicator conversation in outlook and the conversation will be saved to outlook at particular intervals. In case the chat session go beyond this interval, multiple copies of session will be saved with the information at the moment of interval timeout. i.e . The recent copy of the conversation includes all information from previous copy and all older copies can be deleted from outlook folder.

The tools to delete duplicate items didn't help here so I wrote VB script to handle this task myself. Here is the logic
1)Open Conversation History folder
2)Sort items by subject then Received in ascending order to group the items by subject and get the oldest item first among the subject
3) In first step mark the first item as pointer and named as X
4) In subsequent steps compared the subject of current item and previous pointer item (X) and if matches then verified body of item X contained in body of current item
5) If so then delete the item X
6) Outside the loop make current item as X and continue the loop

VB Script:

Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set objFldr = objNamespace.Folders.Item("Mailbox - Ramasamy, Yuvaraj").Folders.Item("Conversation History")
Set colItems = objFldr.Items
colItems.Sort "[Subject][Received]", false
item_comp = Null
WScript.Echo colItems.count
For Each objItem in colItems

If isNUll(item_comp ) then
set item_comp = objItem
elseif (item_comp.subject = objItem.subject) then
If left(objItem.body,len(item_comp.body)) = item_comp.body then
item_comp.Delete
end if
end if
set item_comp = objItem
Next
WScript.Echo "all done"

Enter your Comments