Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help...

Status
Not open for further replies.

buccaneers

Programmer
Jun 3, 2004
28
US
Hello Gurus,

I am new what at awk and easily getting lost. I am stuck now and would really appreciate your help. Here is what I am trying to achieve as output from the input file mentioned below :-

EXPECTED OUTPUT :-
Date Time sylogina1 sylogina2 others Total
Feb 21 2006 12:00AM 2 1 1 4
Feb 21 2006 12:10AM 2 2
Feb 21 2006 12:20AM 0


INPUT FILE CONTAINS FOLLOWING LINES:-

--------------------------
Feb 21 2006 12:00AM

-------------------------------------------------------------------------
List of Processes where TableScans are more than 10000 pages in 5 minutes
SPID KPID CPUTime PhysicalReads TableAccesses IndexAccesses Transactions Application Login
ClientHost ClientIP ClientOSPID
------ ----------- ----------- ------------- ------------- ------------- ------------ ------------------------------ --------------------------
---- ------------------------------ ------------------------ ------------------------------
574 200868197 7500 -26154 102056 -4175520 0 NULL sylogina1
NULL NULL 6352
558 232063384 8800 -73762 100563 -4382005 0 NULL syspoper1
NULL NULL 6352
45 1521746431 10000 -95351 98227 -4580323 0 NULL sylogina1
NULL NULL 6352
545 1521746431 10000 -95351 98227 -4580323 0 NULL sylogina2
NULL NULL 6352
SPID of the highest count of Table Scans in this sample period is: '574'
SPID KPID BatchID SequenceInBatch SQLText


------ ----------- ----------- --------------- ------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------------------
---------------
PlanID SPID KPID BatchID ContextID SequenceNumber DBID ProcedureID PlanText

----------- ------ ----------- ----------- ----------- -------------- ----------- ----------- -------------------------------------------------
---------------------------------------------------------------------------------------------------------------

--------------------------
Feb 21 2006 12:10AM

-------------------------------------------------------------------------
List of Processes where TableScans are more than 10000 pages in 5 minutes
SPID KPID CPUTime PhysicalReads TableAccesses IndexAccesses Transactions Application Login
ClientHost ClientIP ClientOSPID
------ ----------- ----------- ------------- ------------- ------------- ------------ ------------------------------ --------------------------
---- ------------------------------ ------------------------ ------------------------------
5 1521746431 10000 -95351 98227 -4580323 0 NULL sylogina1
NULL NULL 6352
49 1521746431 10000 -95351 98227 -4580323 0 NULL sylogina1
NULL NULL 6352

--------------------------
Feb 21 2006 12:20AM

-------------------------------------------------------------------------
List of Processes where TableScans are more than 10000 pages in 5 minutes
SPID KPID CPUTime PhysicalReads TableAccesses IndexAccesses Transactions Application Login
ClientHost ClientIP ClientOSPID
------ ----------- ----------- ------------- ------------- ------------- ------------ ------------------------------ --------------------------
---- ------------------------------ ------------------------ ------------------------------

--------------------------
Feb 21 2006 12:30AM

-------------------------------------------------------------------------
List of Processes where TableScans are more than 10000 pages in 5 minutes
SPID KPID CPUTime PhysicalReads TableAccesses IndexAccesses Transactions Application Login
ClientHost ClientIP ClientOSPID
------ ----------- ----------- ------------- ------------- ------------- ------------ ------------------------------ --------------------------
---- ------------------------------ ------------------------ ------------------------------




TIA,
 
A starting point:
awk '
BEGIN{
fmt="%-12.12s%-9.9s%-10.10s%-10.10s%-7.7s%-5.5s\n"
printf fmt,"Date","Time","sylogina1","sylogina2","others","Total"
}
$NF~/[0-9]:[0-9][0-9][AP]M$/{p();dt=$0;a=b=t=0;next}
NF!=9 || $1!~/^[0-9]+$/{next}
$9=="sylogina1"{++a}
$9=="sylogina2"{++b}
{++t}
END{p()}
function p( x){
if(split(dt,x)!=4)return
printf fmt,x[1]" "x[2]" "x[3],x[4],a,b,t-a-b,t
}
' /path/to/input > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
[tt]awk -f sum_log.awk the_log_file[/tt]

sum_log.awk:
Code:
4==NF && $4 ~ /^..:....$/ {
  report( date, time, s1, s2, total )
  time = $4 ; $4 = ""
  date = $0
  s1 = s2 = total = ""
}

9==NF && $1 ~ /^[0-9]+$/ {
 if ($NF ~ /^sylogina1/)  s1++ 
 if ($NF ~ /^sylogina2/)  s2++ 
 total++
}

END { report( date, time, s1, s2, total ) }

function report( date,time,s1,s2,total     , fmt, others )
{ fmt = "%-12s%-7s %-9s %-9s %-6s %s\n"
  if (!date)
    printf fmt, "Date", "Time", "sylogina1", "sylogina2",
      "others", "Total"
  else
  { total += 0
    others = total - s1 - s2
    if (!others)  others = ""
    printf fmt, date, time, s1, s2, others, total
  }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top