
senthilkumar_ak
Novice
Aug 15, 2008, 1:35 AM
Post #1 of 4
(1833 views)
|
|
Lightbulb Efficient way to take count for multiple strings from a huge log file.
|
Can't Post
|
|
Hi all, I have a huge log [more than 1 GB] file generate from server everyday. I am checking the all exception from the file, send count for each every exception and transaction. The log contains 24 hour data and I need to take only for a time 5:00 am to 5:00 pm. I used a shell script to do it but its take huge time. I will explain here how I have done in the shell script. I used the command SED for taking 5 to 5 from the log file first like the below sed -n "/: 05:/,/: 18:/p" Trace.log > temp.log And then taking count for each exception like this. E1= `grep –ic “DataException” temp.log E2= `grep –ic “DBException” temp.log Totalexception = E1+ E2 | bc -l Some time I want to search for two strings {means if the first string available in the line then search for the next string among the output} where I used count=`cat count_gcbs.log | grep -i “LimitsBusinessLogic” | grep -ic “DBUnexpectedException”` and displaying the total count. My problem is this script is taking huge time and I am greping the string again & again in the file and opening the file frequently. I know this will be done in perl very quick and easily. So please help me on this Is there any way is available to tune my script using perl. log file snippet Worker#1665jennings50CLI: 05:05:16 902 ChangeLimitsBusinessLogic.validateCorpLimits Entry Worker#1665jennings50CLI: 05:05:16 902 ChangeLimitsBusinessLogic.getContactSummary Entry Worker#1665jennings50CLI: 05:05:16 903 ChangeLimitsBusinessLogic.getContactSummary Got contact from GOPM Worker#1665jennings50CLI: 05:05:16 903 ChangeLimitsBusinessLogic.getContactSummary Exit Worker#1665jennings50CLI: 05:05:16 903 ChangeLimitsBusinessLogic.doAuditInsert Entry Worker#1665jennings50CLI: 05:05:16 903 ChangeLimitsBusinessLogic.doAuditInsert Exit Worker#1665jennings50CLI: 05:05:16 903 ChangeLimitsBusinessLogicHelper.hasPassedSLACheck Entry Worker#1665jennings50CLI: 05:05:16 985 ChangeLimitsBusinessLogicHelper.hasPassedSLACheck Exit Regards, senthil kumar ak
|