Input:
Feb 15 2014 09:31:00 ERROR {http--0.0.0.0-0000-000} [54d70-54d70-54d70-54d70-54d70][478-478-478-478-478] JabberServlet - Provisioning exception while parsing protocol
Feb 15 2014 09:31:00 ERROR {http--0.0.0.0-0000-000} [54d70-54d70-54d70-54d70-54d70][478-478-478-478-478] JabberServlet - Failed to extract text from response
Feb 15 2014 09:31:00 ERROR {http--0.0.0.0-0000-000} [54d70-54d70-54d70-54d70-54d70][478-478-478-478-478] JabberServlet - Error while loading make model
Feb 15 2014 10:31:00 ERROR {http--0.0.0.0-0000-000} [54d70-54d70-54d70-54d70-54d70][478-478-478-478-478] JabberServlet - Failed to extract text from response
Feb 15 2014 10:35:00 ERROR {http--0.0.0.0-0000-000} [54d70-54d70-54d70-54d70-54d70][478-478-478-478-478] JabberServlet - Failed to extract text from response
Feb 15 2014 10:41:00 ERROR {http--0.0.0.0-0000-000} [54d70-54d70-54d70-54d70-54d70][478-478-478-478-478] JabberServlet - Provisioning exception while parsing protocol

Desired Output:
Provisioning exception while parsing protocol 2
Failed to extract text from response 3
Error while loading make model 1

So far it is simple. this cane be achieved by the below script. This includes grepping only expection lines form log file.
cat test_with_exceptions.log | grep ERROR | grep -v ERROR_SERVER | cut -d" " -f10- | awk '{count[$1]++; } END {for (i in count) print i, count[i]; }'

QUESTION:
1. How do i get these values on a runinng (Live) log file? I can use "tail -F" but have an issue. I need to print the results once every 15 minutes and not at the end. how do i achieve this?

Thanks in advance

I have tried few options and finally narrowd down to this.. but still not working as desired. Can anyone please debug?

cat core_local_with_exceptions.log | grep ERROR | grep -v ERROR_SERVER | cut -d" " -f10- | awk 'BEGIN {st=system("date +%s")} {count[$0]++;et=system("date +%s"); if (($et-$st) >= 60) {for (i in count) print i, count[i]; $st=$et}}'

I am setting the st (start time in time stamp) in begin and comparing with end time (et). if end_time - start_time >= 60 only I need to print. but it doenst seem to work as desired. Pl help

I am able to get it a bit further..

cat core_local_with_exceptions.log | grep ERROR | grep -v ERROR_SERVER | cut -d" " -f10- | awk 'BEGIN {"date +%s"|getline st} {count[$0]++; sleep 1; "date +%s"|getline et; print "start time..." st "end Time... " et; if ((et-st) >= 5) {for (i in count) {print i, count[i]; st=et}}}' > a.log

This is the output I am getting
start time...1394629136end Time...
start time...1394629136end Time...
start time...1394629136end Time...
start time...1394629136end Time...
start time...1394629136end Time...
start time...1394629136end Time...

The question is why am I not getting end time into variable et when it is similar to start time st?

Pl help

Thanks Guys.. I finally managed to get it..

cat core_local_with_exceptions.log | grep ERROR | grep -v ERROR_SERVER | cut -d" " -f10- | awk 'BEGIN {cmd1="date +%s"; cmd1|getline st; close(cmd1);} {count[$0]++; cmd="date +%s"; cmd |getline et; close(cmd); print "start time..." st "end Time... " et "diff...." et-st; if ((et-st) >= 1) {for (i in count) {print i, count[i]; st=et}}}' > a.log

Now next step is to replace cat wth tail -F and keep writing it to file...let me see how to do it.

This article has been dead for over six months. Start a new discussion instead.