Compare unique ID's to Create and Delete Times


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Compare unique ID's to Create and Delete Times
# 1  
Old 11-21-2008
Compare unique ID's to Create and Delete Times

I have thousands of lines a day of data I would like to sort out. Every sessions has the 3 lines below. I want to figure out each sessions length from Creation to Deletion. Every one has a unique session ID

logevent3:<190>Nov 20 08:41:06 000423df255c[4627]: 6|4096|RC|CAC: Created CAC session ID 0000019d1a5501ad7f32 due to Seachange server request|

logevent3:<190>Nov 20 09:06:15 000423df255c[4627]: 6|4145|RC|CAC: Terminated CAC session 0000019d1a5501ad7f32|

logevent3:<190>Nov 20 09:06:15 000423df255c[4627]: 6|4097|RC|CAC: Deleted session ID 0000019d1a5501ad7f32 due to Seachange server request|

logevent3:<190>Nov 20 08:09:13 000423df255c[4627]: 6|4096|RC|CAC: Created CAC session ID 000041df18d50268a8b9 due to Seachange server request|

logevent3:<190>Nov 20 09:39:41 000423df255c[4627]: 6|4145|RC|CAC: Terminated CAC session 000041df18d50268a8b9|

logevent3:<190>Nov 20 09:39:41 000423df255c[4627]: 6|4097|RC|CAC: Deleted session ID 000041df18d50268a8b9 due to Seachange server request|
So what I was thinking about if it's possible is to have. So for the above session it would look like

Session ID Create Time Delete Time Session Length
0000019d1a5501ad7f32 Nov 20 08:41:06 Nov 20 09:06:15 25:09 min
000041df18d50268a8b9 Nov 20 08:09:13 Nov 20 09:39:41 90:28 min

Some of these could be a couple hours in length as well
# 2  
Old 11-21-2008
Try something like this,

Code:
awk -F'[>| ]'  'BEGIN { print "Session ID      Create Time   Delete Time   Session   Length"}
		       { for(i=8;i++<=NF;)  if ($i~/[0-9]+[a-zA-Z]+/) {split($4 ,a,":");
                         if (b[$i]++==0) {d1=$2OFS$3OFS$4; s1=a[1]*3600+a[2]*60+a[3]} 
                         if (b[$i]==3)   {d2=$2OFS$3OFS$4; s2=a[1]*3600+a[2]*60+a[3]; 
                         printf"%s %s %s %s:%02d min\n", $i, d1, d2, int((s2-s1)/60), (s2-s1)%60}}}' file


Based on your sample, I'm assuming the ID field is somewhere after field 8, and is a combination of numbers & letters.
# 3  
Old 11-22-2008
Rubin,

Thanks it worked, kind of.

This is what your command produced.
000041e910c3028af739 Nov 22 21:45:24 Nov 22 21:45:28 0:04 min

This is the data from the file
$ grep 000041e910c3028af739 logevent
<190>Nov 22 21:21:56 000423df255c[4627]: 6|4096|RC|CAC: Created CAC session ID 000041e910c3028af739 due to Seachange server request|
<190>Nov 22 21:45:28 000423df255c[4627]: 6|4145|RC|CAC: Terminated CAC session 000041e910c3028af739|
<190>Nov 22 21:45:28 000423df255c[4627]: 6|4097|RC|CAC: Deleted session ID 000041e910c3028af739 due to Seachange server request|

The Dates don't line up. Looks like it reading the create time from another line. Any other input would be great.
Not sure if it matters, but above lines of data are spaced by many other lines of data.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Replace string and create new file multiple times

First of all, apologies if this has already been answered elsewhere. I haven't quite been able to find what I'm looking for yet, so hopefully this won't come across as repetition. I have a file consisting of ~100 nearly identical lines, each of which contains multiple instances of the string I... (11 Replies)
Discussion started by: pseudo.seppuku
11 Replies

2. Shell Programming and Scripting

Script to create unique look-up for headers for a Dictionary

I have a text file in UTF-8 format which has the following data structure HEADWORD=gloss1,gloss2,gloss3 etc I want to convert it so that all the glosses of the HeadWord appear on separate lines HEADWORD=gloss1 HEADWORD=gloss2 HEADWORD=gloss3 An example will illustrate the requirement... (4 Replies)
Discussion started by: gimley
4 Replies

3. Shell Programming and Scripting

Delete unique rows - optimize script

Hi all, I have the following input - the unique row key is 1st column cat file.txt A response C request C response D request C request C response E request The desired output should be C request (7 Replies)
Discussion started by: varu0612
7 Replies

4. Shell Programming and Scripting

compare 2 files and return unique lines in each file (based on condition)

hi my problem is little complicated one. i have 2 files which appear like this file 1 abbsss:aa:22:34:as akl abc 1234 mkilll:as:ss:23:qs asc abc 0987 mlopii:cd:wq:24:as asd abc 7866 file2 lkoaa:as:24:32:sa alk abc 3245 lkmo:as:34:43:qs qsa abc 0987 kloia:ds:45:56:sa acq abc 7805 i... (5 Replies)
Discussion started by: anurupa777
5 Replies

5. UNIX for Dummies Questions & Answers

Delete rows with unique value for specific column

Hi all I have a file which looks like this 1234|1|Jon|some text|some text 1234|2|Jon|some text|some text 3453|5|Jon|some text|some text 6533|2|Kate|some text|some text 4567|3|Chris|some text|some text 4567|4|Maggie|some text|some text 8764|6|Maggie|some text|some text My third column is my... (9 Replies)
Discussion started by: A-V
9 Replies

6. Shell Programming and Scripting

Compare multiple files and print unique lines

Hi friends, I have multiple files. For now, let's say I have two of the following style cat 1.txt cat 2.txt output.txt Please note that my files are not sorted and in the output file I need another extra column that says the file from which it is coming. I have more than 100... (19 Replies)
Discussion started by: jacobs.smith
19 Replies

7. Programming

Compare times to run a program - Serial vs MPI

Hi, I have a fortran program with serial and MPI version. I want to compare the time taken by these programs to run. I use ifort/gfortran compiler. How to compare the time taken by each program to run? Is there any sample code for comparison? Thanks, rpd (1 Reply)
Discussion started by: rpd25
1 Replies

8. Shell Programming and Scripting

Create unique tar archives from a list of directories

I'm looking to archive a client directory from a CIFS share There are multiple directories that will be stored in a text file and I'm looking to create an individual tar archive of each folder in the directory. I've tried a number of commands to no avail. Here's what I would like. ... (2 Replies)
Discussion started by: Steelysteel
2 Replies

9. Shell Programming and Scripting

awk - find average interarrival times for each unique page

All, I have a test file as specified below. 1st col is <arrival time> and 2nd col is <Page #>. I want to find the inter-arrival time of requests for each page # (I've done this part already). Once I have this, I want to calculate the average interarrival time. Note, that I am trying to have the... (11 Replies)
Discussion started by: jontjioe
11 Replies

10. Programming

Compare two files of 4 columns and o/p unique,append zero's

I have to files File1 1 23 2 34 3 7 4 56 5 61 6 22 7 65 File2 2 21 4 32 7 22 Now i need to compare column1 of both the files and generate a third file which should contain all the values of 1st column of 1st file and in the second column i need to get the coressponding row... (2 Replies)
Discussion started by: kamuju
2 Replies
Login or Register to Ask a Question