Find sessionids after match


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find sessionids after match
# 15  
Old 06-10-2015
Can we do like whenever 'session out' keyword is encountered then only this command show its magic. As there are millions of sessionID (or duplicate) but we are considering only those which are encountered after 'session out'
# 16  
Old 06-10-2015
This starts after the first "session out":
Code:
awk '
(start==1) {
  for (i=2;i<=NF;i++) if ($(i-1)=="sessionId") {
    addr=NR "(" $1 FS $2 ")"
    if ($i in s) {
      print "duplicate",$i,"in lines",s[$i],"and",addr
    } else {
      s[$i]=addr
    }
    break
  }
}
/session out/ { start=1 }
' file.log

---------- Post updated at 02:03 PM ---------- Previous update was at 01:56 PM ----------

Your first post lets me think you want to search for duplicates only between two "session out"'s.
Then one needs to clear the s[] array when a "session out" is encountered.
Code:
awk '
{
  for (i=2;i<=NF;i++) if ($(i-1)=="sessionId") {
    addr=NR "(" $1 FS $2 ")"
    if ($i in s) {
      print "duplicate",$i,"in lines",s[$i],"and",addr
    } else {
      s[$i]=addr
    }
    break
  }
}
/session out/ {
  split("",s) # this trick clears the array
}
' file.log

# 17  
Old 06-10-2015
Sorry about the confusion.

Actual scenario is like whenever 'session out' is grepped, system should find next immediate sessionID and compare it with next sessionIDs generated or destroyed.

please see below sample code:
Code:
 
 
2015-05-31 09:16:26,518 WARN  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-57] [LoggedInFilter ] session out
2015-05-31 09:16:26,518 WARN  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-57] [LoggedInFilter ] Processing request  uri /lis/InvokerServlet/java:global//lisserverapp/GlobalControllerEJB/editingComplete
2015-05-31 09:16:26,519 WARN  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-57] [LoggedInFilter ] userId null | system /lis | action null | sessionId ZNBqudEfoWnrBn4to0aMAAie | hasActiveSession false | hasMultipleSessionAccess false | hasMultipleSessionAccess false
2015-05-31 09:16:26,678 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [PerformanceUtil  |lis]  Tracking for : processMessage : (1) serviceLookup > 0 : (2) clientInfo > 0 : (3) proxy.execute > 24 : (4) Total > 24
2015-05-31 09:16:26,681 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [InvokerServlet  |lis] ap01-lisprd.ctn.ameripath.local Metrics for action=/java:global//lisserverapp/GrossDescriptionControllerEJB/getGrossDescription  4       25      1       31      NA      68
2015-05-31 09:16:26,685 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-57] [SessionListener ] Destroyed session - ZNBqudEfoWnrBn4to0aMAAie for  Unknown User|lis
2015-05-31 09:16:27,097 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [PerformanceUtil  |lis] END getUsersForLabRole Tracking for : getUsersForLabRole : (1) getUsersForLabRole > 140 : (2) Total > 140
2015-05-31 09:16:27,105 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [PerformanceUtil  |lis]  Tracking for : processMessage : (1) serviceLookup > 0 : (2) clientInfo > 0 : (3) proxy.execute > 148 : (4) Total > 148
2015-05-31 09:16:27,124 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [InvokerServlet  |lis]  Metrics for action=/java:global//lisserverapp/UserControllerEJB/getUsersForLabRole       3
       149     17      170     NA      68
2015-05-31 09:16:27,302 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [FrameworkServicesEJB  |lis] --Called checkOut method for userId 
2015-05-31 09:16:27,314 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [BlackBarDTOMappings  |lis] 
2015-05-31 09:55:21,028 WARN  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-26] [LoggedInFilter ] session out
2015-05-31 09:55:21,028 WARN  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-26] [LoggedInFilter ] Processing request AND uri /lis/InvokerServlet/java:global/pathway/lisserverapp/GlobalControllerEJB/editingComplete
2015-05-31 09:55:21,029 WARN  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-26] [LoggedInFilter ] userId null | system /lis | action null | sessionId MwfQakeHv0MZ3wfwX2V-vgln | hasActiveSession false | hasMultipleSessionAccess false | hasMultipleSessionAccess false
2015-05-31 09:55:21,080 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-26] [SessionListener ] Destroyed session - MwfQakeHv0MZ3wfwX2V-vgln for  Unknown User|lis
2015-05-31 09:55:21,222 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-34] [PerformanceUtil |lis]  Tracking for : processMessage : (1) serviceLookup > 0 : (2) clientInfo > 0 : (3) proxy.execute > 16 : (4) Total > 16
2015-05-31 09:55:21,224 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-34] [InvokerServlet |lis] etrics for action=/java:global/pathway/lisserverapp/GlobalControllerEJB/editingComplete      2
       17      1       20      NA      70
2015-05-31 09:55:21,287 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [FrameworkServicesEJB  |lis] --Called checkOut method for userId  
2015-05-31 09:55:21,300 INFO  [http-ap01-lisprd.ctn.ameripath.local/156.30.179.17:8080-19] [BlackBarDTOMappings  |lis]

# 18  
Old 06-10-2015
If only the first sessionID after "session out" is to be searched for duplicates including the destroyed sessions, until the next "session out",
i.e. the second sessionID is NOT searched for duplicates,
then we have an array with only one element.
That also means that each first sessionID is reported duplicate when it is destroyed.
Code:
awk '
/session out/ {
  split("",s) # this trick clears the array
  first=1
  next
}
{
  addr=NR "(" $1 FS $2 ")"
  if (first) {
    for (i=3;i<NF;i++)
      if ($i=="sessionId") {
        s[$(i+1)]=addr
        first=0
        break
      }
  } else {
    for (i=4;i<=NF;i++)
      if ($i in s) {
        print "duplicate",$i,"in lines",s[$i],"and",addr
        break
      }
  }
}
' file.log

# 19  
Old 06-11-2015
So this means the above posted code will pick each sessionID after 'session out' and find for duplicates.
# 20  
Old 06-18-2015
Madeingermany, can you please throw some light on command you gave me.
Each command you send me giving me same result.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Match file and find count

Hi All, I have transaction in one file.I want to match that to another file and find the number of time the transaction is available on the other file.I need to take each record from TRANSFILE and match that with SPEND FILE and find the number of counts of the transaction TRANSFILE: ... (4 Replies)
Discussion started by: arunkumar_mca
4 Replies

2. Shell Programming and Scripting

Find the exact and best match between 2 files

Dear Forum, File1: Reference 4474189 United Kingdom Mobile 4474188 United Kingdom Mobile 4474187 United Kingdom Mobile 447 United Kingdom 93 AFGHANISTAN 0093 1907 ALASKA 001907 355 ALBANIA 00355 35568 ALBANIA MOBILE 0035568 35569 ALBANIA MOBILE 0035569 213 ALGERIA 00213 2137 ALGERIA... (2 Replies)
Discussion started by: yahyaaa
2 Replies

3. UNIX for Dummies Questions & Answers

Find match between two datasetsand add value

Dear all, could you help with following: i have two large datasets that contain two columns. dataset1: 752566 rs3094315 752721 rs3131972 753541 rs2073813 760300 rs11564776 768448 rs12562034 776546 rs12124819 dataset2: 55550 0.000000 82571 0.080572 88169 0.092229... (3 Replies)
Discussion started by: kush
3 Replies

4. Shell Programming and Scripting

Use of sed to find everything after first match!

Hi Guys So far I have got this to work: set x = temp1:temp2:temp3 echo $x | sed 's/.*:\(.*\).*/\1/' Answer: temp3 But I want answer as temp2:temp3, that is everything after the first ":" is found. If anybody can help with a bit of description that will be great. Thanks in Advance (1 Reply)
Discussion started by: dixits
1 Replies

5. Shell Programming and Scripting

Help me with s script to find exact match

Hi, im extracting data from oracle DB. As the data is case sensitive, i have to extract the data which doesn't match exactly. im poor in unix scripting, can someone plz help me with a script. Here are the details. Need to compare the second column of the each line of the file1.csv with the data in... (5 Replies)
Discussion started by: JSKOBS
5 Replies

6. Shell Programming and Scripting

Find out match characters on all lines

I have a file with 22 lines. Each line has only 5 different chars, no white space, and each line is 3,278,824 in length. The 5 chars is "-", "A", "B", "C", "D". Below is an example of the first 25 chars of the first four lines of the file. -----ABCDA--CD-BBBBB----D --A--ABCD--DCD-BBBBC-----... (12 Replies)
Discussion started by: cwzkevin
12 Replies

7. Shell Programming and Scripting

Match look up file and find result

Hi I ahve a lookup file wiht seven words CD HT CAD HT T1D T2D BDanother file contain data like this CHRM1 P11229 Pirenzepine DAP000492 Peptic ulcer disease Approved T2D CHRM1 P11229 Glycopyrrolate DAP001116 Anesthetic Approved T2D CHRM1 P11229 ... (7 Replies)
Discussion started by: manigrover
7 Replies

8. Shell Programming and Scripting

Find out the match data content?!

Hi, Long list of Input file1 content: 1285_t 4860_i 4817_v 8288_c 9626_a . . . Long list of Input file2 content: 1285_t chris germany 8288_c steve england 9626_a dave swiss 9260_s stephanie denmark . . . (14 Replies)
Discussion started by: patrick87
14 Replies

9. Shell Programming and Scripting

find: No match due to find command being argument

I am using csh and getting the error "find: No match." but I cannot figure out why. What I am trying to do is set the find command to a variable and then execute the variable as a command. I ran it through a debugger and it looks like $FIND is getting set but the find command can not actually be... (2 Replies)
Discussion started by: mst3k4l
2 Replies

10. Shell Programming and Scripting

How to find first match and last match in a file

Hi All, I have a below file: ================== 02:53 pravin-root 02:53 pravin-root 03:05 pravin-root 02:55 pravin1-root 02:59 pravin1-root ================== How do I find the first and last value of column 1. For example, how do I find 02:53 is the first time stamp and 03:05 is... (3 Replies)
Discussion started by: praving5
3 Replies
Login or Register to Ask a Question