Log Analysis with AWK with Time difference


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Log Analysis with AWK with Time difference
# 1  
Old 09-20-2011
Log Analysis with AWK with Time difference

I would like to write a shell script that calculated the time difference bettween the log entries. If the time difference is higher as 200 sec. print the complette lines out.
My Problem is, i am unable to jump in the next line and calculate the time difference.

Thank you for your Help.



My log entries in a file:
Code:
2011-09-13 16:27:59,334 DEBUG [http-10.99.8.212-10000-1:] [domin.a.xy.ade] Start ALG: 0ms
2011-09-13 16:27:59,334 INFO  [http-10.99.8.212-10000-1:] [domin.a.xy.ade2123] Used Key156161;


Moderator's Comments:
Mod Comment Please use code tags!

Last edited by radoulov; 09-20-2011 at 03:32 PM..
# 2  
Old 09-20-2011
Hi fabian3010,

Those entries shouldn't be printed because difference between them is 0 seconds, am I right?

Regards,
Birei
# 3  
Old 09-20-2011
I would suggest using perl for date and time arithmetic because doing it in the shell can be very cumbersome and prone to errors.
# 4  
Old 09-22-2011
@berei, thats really right. e.x. in this case is the time difference to high print the two lines on a console.

Code:
2011-09-13 16:27:59,334 DEBUG [http-10.99.8.212-10000-1:] [domin.a.xy.ade] Start ALG: 0ms
2011-09-13 16:28:01,334 INFO  [http-10.99.8.212-10000-1:] [domin.a.xy.ade2123] Used Key156161;

@shamrock do you have an example for me ? in this case ?
# 5  
Old 09-22-2011
But, how many entries are there in the log file? Only two? In case of 11 entries, how should be the output?

I think you sould provide a bigger example to be sure.

Regards,
Birei
# 6  
Old 09-22-2011
Provide a good sample of the input and the expected output...
Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk script to find time difference between HTTP PUT and HTTP DELETE requests in access.log

Hi, I'm trying to write a script to determine the time gap between HTTP PUT and HTTP DELETE requests in the HTTP Servers access log. Normally client will do HTTP PUT to push content e.g. file_1.txt and 21 seconds later it will do HTTP DELETE, but sometimes the time varies causing some issues... (3 Replies)
Discussion started by: Juha
3 Replies

2. UNIX for Dummies Questions & Answers

Shell script - getting Time difference using awk

Hi..I have the data in a file like in this format, and I need the output time difference in seconds by using awk command. Start date/time and end date/time given in column 2,3 & 4,5. Please assist how to write shell script. File1.txt JOB1 10/09/2013 17:42:16 10/09/2013 17:43:46 SU 6202685/1... (4 Replies)
Discussion started by: mprithvi
4 Replies

3. Shell Programming and Scripting

Check/Parse log file's lines using time difference/timestamp

I was looking at this script which outputs the two lines which differs less than one sec. #!/usr/bin/perl -w use strict; use warnings; use Time::Local; use constant SEC_MILIC => 1000; my $file='infile'; ## Open for reading argument file. open my $fh, "<", $file or die "Cannot... (1 Reply)
Discussion started by: cele_82
1 Replies

4. Shell Programming and Scripting

Date and time range extraction via Awk or analysis script?

Hello does anyone know of an awk that will extract log file entries between a specific date and time range, eg: awk '/15\/Dec\/2010:16:10:00/, /15\/Dec\/2010:16:15:00/' access_log but one that works? Or a free command line log file analysis tool/script? I'd like to be able to view... (2 Replies)
Discussion started by: competitions
2 Replies

5. Shell Programming and Scripting

compare the log and display the time difference..

Hi All, I've written a script which reads all the systems backup information and saves it in a log file. #!/bin/ksh export ORACLE_SID=$1 export primaryhost=$2 export sid=`echo $ORACLE_SID| tr ` RESULTFILE=/oracle/PC9/backupstatus_prod.log LOGP=`ssh -o StrictHostKeyChecking=no -l... (1 Reply)
Discussion started by: suri.tyson
1 Replies

6. Shell Programming and Scripting

To find the time difference between two lines of the same log file

Hello Friends, I want to write a script for the following: nlscux62:tibprod> grep "2008 Apr 30 01:" SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2.log | grep -i post | more 2008 Apr 30 01:01:23:928 GMT +2 SAPAdapter.SA_EHV_SPEED_SFC_IN_03-SA_EHV_SPEED_SFC_IN_03-2 Info AER3-000095 IDOC... (2 Replies)
Discussion started by: satyakam
2 Replies

7. UNIX for Advanced & Expert Users

WEB Server Log File Analysis using awk/sed/grep

I'm trying to find a way to show large page sizes (page size in K) from multiple web server log files. Essentially I want to show only rows from a file where a specific column is larger than some value. Has anyone ever done this type of log analysis? If so, a snippet of code would be very... (2 Replies)
Discussion started by: mike_cataldo@ad
2 Replies
Login or Register to Ask a Question