awk : Search for text between two time frame (12 hours)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk : Search for text between two time frame (12 hours)
# 22  
Old 11-23-2013
Appreciate your help and Sorry to keep bothering you.

PFA data.log.txt, kindly copy this to your linux box and use for your testing

can you help me to collect complete log details only
"'from=2013 11 19 09 50 49' 'to=2013 11 19 10 00 49'"...

while doing test if possible please check time "21 50" to "22 00" after modify the data file "AM" to "PM".
# 23  
Old 11-26-2013
Okay, this is a definite example of data it messes up on. Working on it.
# 24  
Old 11-26-2013
Okay, I think I see the error. It's okay for a range of data to end after to as long as it begins within the given range. Are those <TEST kernel> lines really supposed to be wrapped, though? Grabbing those after the 10:51 doesn't make sense if they're wrapped.

Last edited by Corona688; 11-26-2013 at 03:01 PM..
# 25  
Old 11-26-2013
Code:
$ cat dconv3.awk

BEGIN {
        FS="[#<> ,:]+"
        # Build tables so MON["Jan"] becomes 1, etc.
        split("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec", M);
        for(X in M) MON[M[X]]=X
        for(X=1; X<=11; X++) { T[X"AM"]=X ; T[X"PM"]=X+12 }
        T["12PM"]=12;        T["12AM"]=24;
}

/####/ {
        YYMMDD=sprintf("%04d %02d %02d %02d %02d %02d",
                $4, MON[$2], $3, T[$5 $8], $6, $7);

        S=E
        E=YYMMDD

        if((S >= from) && (S <= to))
        {
                for(X=1; X<=LINE; X++) print A[X];
                print
                LINE=0
                next
        }

        LINE=0
}

{       if(S||E) A[++LINE]=$0   }


$ awk -f dconv3.awk 'from=2013 11 19 09 50 49' 'to=2013 11 19 10 00 49' data.log.txt
####<Nov 19, 2013 9:50:50 AM UTC> <Error> <Socket> <hostname> <abcd-123-12-1> <ExecuteThread: '2' for queue: 'weblogic.socket.Muxer'> <
<TEST Kernel>> <> <> <1384828250396> <BAB-123> <Uncaught Throwable in processSockets
 java.lang.NoClassDefFoundError: java/lang/IOException.
java.lang.NoClassDefFoundError: java/lang/IOException
        at jrockit.ext.epoll.EPoll.epollCtl0(Native Method)
        at jrockit.ext.epoll.EPoll.epollEnableOneshot(EPoll.java:87)
        at weblogic.sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socket.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.sxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
>
####<Nov 19, 2013 9:51:50 AM UTC> <Error> <Socket> <hostname> <abcd-123-12-1> <ExecuteThread: '0' for queue: 'weblogic.socket.Muxer'> <
<TEST Kernel>> <> <> <1384828310409> <BAB-123> <Uncaught Throwable in processSockets
 java.lang.NoClassDefFoundError: java/lang/IOException.
java.lang.NoClassDefFoundError: java/lang/IOException
        at jrockit.ext.epoll.EPoll.epollCtl0(Native Method)
        at jrockit.ext.epoll.EPoll.epollEnableOneshot(EPoll.java:87)
        at weblogic.socketxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socketxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socketxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socketxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socket.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socket.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socket.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socket.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.socket.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.kernel.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
        at weblogic.kernel.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx(xxxxxxxxxxx)
>
####<Nov 19, 2013 10:00:50 AM UTC> <Error> <Socket> <hostname> <abcd-123-12-1> <ExecuteThread: '3' for queue: 'weblogic.socket.Muxer'> <

$

This User Gave Thanks to Corona688 For This Post:
# 26  
Old 11-26-2013
ya, that's fine as long as its not given any repeated details. ( if no data with in range then it won't give any details right)
# 27  
Old 11-26-2013
If none of the data is ever in range, it shouldn't print anything. See post #25, where I've updated the code again. It doesn't grab the lines you wanted after the 10:50 though, since logically speaking, it shouldn't be grabbing any lines after 10:50. I'm not sure how I would handle that case if they're utterly necessary.
# 28  
Old 11-26-2013
Awesome, it's working perfectly .... "After line 10:50" - may be instead of checking every 15 mins I will mention 20 or 25 min" so that will get the alerts in the next cron checking.

you're the man, Thanks lot Smilie
This User Gave Thanks to zenkarthi For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Need to filter the result set within 2 time frame

my sample file is like this $cat onefile 05/21/18 13:10:07 ABRT US1CPDAY Status 1 05/21/18 21:18:54 ABRT DailyBackup_VFFPRDAPENTL01 Status 6 05/21/18 21:26:24 ABRT DailyBackup_VFFPRDAPENTL02 Status 6 05/21/18 21:57:36 ABRT DailyBackup_vm-ea1ffpreng01 Status 6... (7 Replies)
Discussion started by: gotamp
7 Replies

2. Shell Programming and Scripting

Help on script to capture info on log file for a particular time frame

Hi I have a system running uname -a Linux cmovel-db01 2.6.32-38-server #83-Ubuntu SMP Wed Jan 4 11:26:59 UTC 2012 x86_64 GNU/Linux I would like to capture the contents of /var/log/syslog from 11:00AM to 11:30AM and sent to this info via email. I was thinking in set a cron entry at that... (2 Replies)
Discussion started by: fretagi
2 Replies

3. Shell Programming and Scripting

Awk:String search more than one time and capture OP

Dear All During one of mine script developemnt i am stuch at one sub part. Requiremnt is as below kindly help me. IP file: 2015-02-28 10:10:15 AL M UtranCell UtranCell=RTE001X (unavailable) 2015-02-28 10:10:15 AL M UtranCell UtranCell=RTE001Y (unavailable) 2015-02-28 10:10:15 AL M... (6 Replies)
Discussion started by: jaydeep_sadaria
6 Replies

4. UNIX for Dummies Questions & Answers

UNIX Account getting Locked Everyday between same Time Frame

I am facing an Issue with a particular Unix Account ( ie a particular Userid) getting LOCKED everyday between 7:30am and 8:00am. The Password associated with this particular Account has been setup such that it should never Expire at all but it does LOCK the Account after more than 3 failed... (5 Replies)
Discussion started by: pchegoor
5 Replies

5. Shell Programming and Scripting

awk : collecting all data between two time frame

Hi Experts , I need your help to collect the complete data between two time frame from the log files, when I try awk it's collecting the data only which is printed with time stamp for example, awk works well from "16:00 to 17:30" but its not collecting <line*> "from 17:30 to 18:00" ... (8 Replies)
Discussion started by: zenkarthi
8 Replies

6. Shell Programming and Scripting

Log search and mail it if the log is updated before 24 hours from the current time

Hi , We have around 22 logs , each has different entries. I have to automate this using shell script. The ideas which am sharing is given below 1) We use only TAIL -100 <location and name of the log> Command to check the logs. 2) We want to check whether the log was updated before 24... (13 Replies)
Discussion started by: Kalaihari
13 Replies

7. Shell Programming and Scripting

Perl : unable to frame code with Business:Hours module with example

Hi all , There are two datetimes in the below format $datetime1="2007-12-31 16:50:00"; $datetime2="2008-1-1 04:24:00"; I need to calculate time in minutes only in between the office hours.(08:00 to 18:00 ). in PERL. For the above requirement I found a module Business::Hours that... (4 Replies)
Discussion started by: scriptscript
4 Replies

8. Shell Programming and Scripting

Search for text between two time frame using sed

I have log files with time stamps. I want to search for text between two time stamp using sed even if the first tme stamp or the last time stamp are not present. For e.g. if i search between 9:30 and 9:40 then it should return text even if 9:30 or 9:40 is not there but between 9:30 and 9:40 is... (8 Replies)
Discussion started by: Azher
8 Replies

9. Shell Programming and Scripting

Shell Script to delete files within a particular time frame under multiple sub folders

Greetings! I'm looking for starting information for a shell script. Here's my scenario: I have multiple folders(100) for example: /www/test/applications/app1/logs /www/test/applications/app2/logs Within these folders there are log files files that need to be deleted after a month. ... (3 Replies)
Discussion started by: whysolucky
3 Replies

10. Shell Programming and Scripting

search string during a specific time frame

Can someone please help me with searching a string during a specific time frame. Below is the format of the time from my log file. "GET /AAM2009_wherewereheaded.wmv HTTP/1.1" 200 52307085 The search string I need is "AAM2009_wherewereheaded.wmv" I need to search the number of... (1 Reply)
Discussion started by: tadi18
1 Replies
Login or Register to Ask a Question