Thursday, June 23, 2016

Rexx to create a CSV dataset from SMF110 (CICS performance records)

Update 5/12/2016 : Add more fields (MQ time, DB2 time ...)
 
This rexx reads the unloaded dataset written from the standard program DFH$MOLS which print SMF110 CICS Performance record. 
The output of DFH$MOLS unfortunately is not easy for analysis 
This Rexx provide a CSV dataset (I like Excel) , with Transaction Id, Elapse and CPU time associated with the number of DB2 requests. This is useful to have quickly a performance indicator of your Information System to compare(Which is mainly CICS and DB2 ...). As SMF110 includes DB2 time, all your consumption is here.
More detailed than SMF30
More convenient than SMF101 (in my shop SMF101 is not collected for CICS transactions because it is really huge) 

Prereq : Execute DFHMNDUP then DFH$MOLS with the UNLOAD option

These rexx are now in CBTTAPE #941 - You can go to cbttape.org to download the xmit file.

/*Rexx*/                                                                00010000
numeric digits 15                                                       00020000
/*-------------------------------------------------------------*/       00030000
/* Report Transaction performance Data                         */       00040000
/* Validated for CICS TS 5.3                                   */       00040106
/* Extract smf 110 records output from dfh$mols unload file    */       00041000
/*                                      ndt.db2@gmail.com      */       00050000
/*  10 Jun 2016     Release 1.0  for CICS 5.2                  */       00060012
/*  23 Nov 2016     Release 1.1  for CICS 5.3                  */       00070012
/*-------------------------------------------------------------*/       00124000
/*Comment : Change datasets high level identifier              */       00125000
/*-------------------------------------------------------------*/       00126000
ARG  hlq                                                                00127000
reci=0                                                                  00140001
reco=0                                                                  00140101
mintime='24:60:00'                                                      00140207
maxtime='00:00:00'                                                      00140307
totcpu=0                                                                00140407
totelap=0                                                               00140509
totdb2r=0                                                               00140609
                                                                        00141001
/* Input file : SMF extract sorted */                                   00150000
oufl = hlq !! '.report.cicmol'                                          00160000
"ALLOC DD(INP) DS('"oufl"') ,                                           00170000
                       SHR REU bufno(20)"                               00180000
                                                                        00190000
/* Report dataset on output */                                          00200000
oufl = "'" !! hlq !! '.report.tran' !! "'"                              00210000
"DELETE" oufl "PURGE"                                                   00220000
                                                                        00230000
"ALLOC FI(OUFL) DA("oufl") NEW CATALOG REUSE" ,                         00240000
"LRECL(600) RECFM(V B) TRACKS SPACE(600,600)"                           00250000
rcalloc = rc                                                            00260000
if rcalloc <> 0 then Do                                                 00270000
     say "**********************************************"               00280000
     say "   Error allocating Tran Report file" rcalloc                 00290000
     say "   Abnormal end  "                                            00300000
     say "**********************************************"               00310000
     Exit 8                                                             00320000
end                                                                     00330000
/* WRITE report header */                                               00360000
CALL write_header                                                       00370000
                                                                        00380000
/* START PROCESSING */                                                  00390000
DO FOREVER                                                              00400000
  /* read input */                                                      00410000
  "EXECIO 1 DISKR INP"                                                  00420000
  IF RC > 0 THEN DO                                                     00430000
            if rc =  2 then                                             00440000
             do                                                         00450000
              SAY 'End of Input file rc=' RC                            00460000
              rcalloc = rc                                              00470000
             end                                                        00480000
             else do                                                    00490000
              SAY 'Error while reading Input file rc=' RC               00500000
              rcalloc = 8                                               00510000
             end                                                        00520000
              leave                                                     00530000
            END                                                         00540000
  PARSE PULL INPUT_REC                                                  00550000
  reci=reci+1                                                           00560000
  Call DECODE                                                           00590000
  Call write_report                                                     01030000
END                                                                     01060000
/* End of processing - close file */                                    01070000
"EXECIO" queued() "DISKW OUFL ( FINIS"                                  01080000
rcwrite = rc                                                            01090000
if rcwrite<> 0 then Do                                                  01100000
   say "**********************************************"                 01110000
   say "   Error writting OUFL file: " rcwrite                          01120000
   say "   Abnormal end   "                                             01130000
   say "**********************************************"                 01140000
   Exit 8                                                               01150000
end                                                                     01160000
"EXECIO 0 DISKR INP (STEM INL. FINIS"                                   01170000
"FREE DD(INP)"                                                          01180000
"FREE DD(OUFL)"                                                         01190000
                                                                        01200000
say "Input records =" reci                                              01210000
say "Output records=" reco                                              01220000
say 'Periode processed' tsdate ' betweeen ' mintime maxtime             01230008
say '    Total Transactions   ' reci                                    01231007
say '    Total cpu =          ' totcpu                                  01231107
say '    Total Elapsed        ' totelap                                 01231209
say '    Total db2requests =  ' totdb2r                                 01232007
                                                                        01290000
EXIT rcalloc                                                            01300000
                                                                        01310000
                                                                        01350000
/* MAP from dfhsamp(DFHMNPDA) */                                        01360000
decode:                                                                 01370000
  jobname  = SUBSTR(INPUT_REC,1,8)                                      01390002
  applid   = SUBSTR(INPUT_REC,9,8)                                      01401002
  SysId    = SUBSTR(INPUT_REC,25,4)                                     01404005
  /* ...*/                                                              01405000
                                                                        01410000
  TranId   = SUBSTR(INPUT_REC,93,4)                                     01410402
  UserId   = SUBSTR(INPUT_REC,101,8)                                    01410602
  /* task start PDRATTT*/                                               01410802
  tunits   = SUBSTR(INPUT_REC,113,8)                                    01410902
  call stck tunits                                                      01411002
  startt=tstime                                                         01411102
  startts=tots                                                          01411205
  /* task stop  PDRDETT*/                                               01411402
  tunits   = SUBSTR(INPUT_REC,121,8)                                    01411503
  call stck tunits                                                      01411602
  stopt=tstime                                                          01411702
  stopts=tots                                                           01411805
  /* pdrdist/ transaction dispatch time  */                             01413010
  offs   = 2329 /* check with the manual corresponding to */            01414011
                /* the CICS version */                                  01414111
  usrdisp  = c2x(SUBSTR(INPUT_REC,offs,8))                              01414211
  usrdisp  = x2d(SUBSTR(usrdisp,1,13)) * 0.000001                       01414311
  /* pdrcput/ usrcput tcb cpu transaction */                            01414511
  offs = offs+12                                                        01414611
  usrcput  = c2x(SUBSTR(INPUT_REC,offs,8))                              01414711
  usrcput  = x2d(SUBSTR(usrcput,1,13)) * 0.000001                       01414811
  /* PDRSUST  User suspend time           */                            01414911
  offs = offs+36                                                        01415011
  usrsusp  = c2x(SUBSTR(INPUT_REC,offs,8))                              01415111
  usrsusp  = x2d(SUBSTR(usrsusp,1,13)) * 0.000001                       01415211
  /* PDRDWT   User Dispatch Wait time     */                            01415311
  offs = offs+12                                                        01415411
  usrwt    = c2x(SUBSTR(INPUT_REC,offs,8))                              01415511
  usrwt    = x2d(SUBSTR(usrwt  ,1,13)) * 0.000001                       01415611
  /* PDRQRDSP QR   Dispatch      time     */                            01415711
  offs = offs+12                                                        01415811
  usrqrdp  = c2x(SUBSTR(INPUT_REC,offs,8))                              01415911
  usrqrdp  = x2d(SUBSTR(usrqrdp,1,13)) * 0.000001                       01416011
  /* PDRQRCPU QR   CPU           time     */                            01416111
  offs = offs+12                                                        01416211
  usrqrcpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01416311
  usrqrcpu = x2d(SUBSTR(usrqrcpu,1,13)) * 0.000001                      01416411
  /* PDRMSDSP Other mode Disp    time     */                            01416511
  offs = offs+12                                                        01416611
  usrotdp  = c2x(SUBSTR(INPUT_REC,offs,8))                              01416711
  usrotdp  = x2d(SUBSTR(usrotdp ,1,13)) * 0.000001                      01416811
  /* PDRMSCPU Other mode Cpu     time     */                            01416911
  offs = offs+12                                                        01417011
  usrotcpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01417111
  usrotcpu = x2d(SUBSTR(usrotcpu,1,13)) * 0.000001                      01417211
  /* PDRRODSP RO    mode Disp    time     */                            01417311
  offs = offs+12                                                        01417411
  usrROdp  = c2x(SUBSTR(INPUT_REC,offs,8))                              01417511
  usrROdp  = x2d(SUBSTR(usrrodp ,1,13)) * 0.000001                      01417611
  /* PDRROCPU RO    mode Cpu     time     */                            01417711
  offs = offs+12                                                        01417811
  usrrocpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01417911
  usrrocpu = x2d(SUBSTR(usrrocpu,1,13)) * 0.000001                      01418011
  /* PDRKY8DS Key8  mode Disp    time     */                            01418111
  offs = offs+12                                                        01418211
  usrk8dp  = c2x(SUBSTR(INPUT_REC,offs,8))                              01418311
  usrk8dp  = x2d(SUBSTR(usrk8dp ,1,13)) * 0.000001                      01418411
  /* PDRKY8CP Key8  mode Cpu     time     */                            01418511
  offs = offs+12                                                        01418611
  usrk8cpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01418711
  usrk8cpu = x2d(SUBSTR(usrk8cpu,1,13)) * 0.000001                      01418811
  /* PDRKY9DS Key9  mode Disp    time     */                            01418911
  offs = offs+12                                                        01419011
  usrk9dp  = c2x(SUBSTR(INPUT_REC,offs,8))                              01419111
  usrk9dp  = x2d(SUBSTR(usrk9dp ,1,13)) * 0.000001                      01419211
  /* PDRKY9CP Key9  mode Cpu     time     */                            01419311
  offs = offs+12                                                        01419411
  usrk9cpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01419511
  usrk9cpu = x2d(SUBSTR(usrk9cpu,1,13)) * 0.000001                      01419611
  /* PDRL8CPU L8    mode Cpu     time     */                            01419711
  offs = offs+12                                                        01419811
  usrl8cpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01419911
  usrl8cpu = x2d(SUBSTR(usrl8cpu,1,13)) * 0.000001                      01420011
  /* PDRL9CPU L9    mode Cpu     time     */                            01420111
  offs = offs+12                                                        01420211
  usrl9cpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01420311
  usrl9cpu = x2d(SUBSTR(usrl9cpu,1,13)) * 0.000001                      01420411
  /* PDRS8CPU S8    mode Cpu     time     */                            01420511
  offs = offs+12                                                        01420611
  usrs8cpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01420711
  usrs8cpu = x2d(SUBSTR(usrs8cpu,1,13)) * 0.000001                      01420811
  /* PDRX8CPU X8    mode Cpu     time     */                            01420911
  offs = offs+12                                                        01421011
  usrx8cpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01421111
  usrx8cpu = x2d(SUBSTR(usrx8cpu,1,13)) * 0.000001                      01421211
  /* PDRX9CPU X9    mode Cpu     time     */                            01421311
  offs = offs+12                                                        01421411
  usrx9cpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01421511
  usrx9cpu = x2d(SUBSTR(usrx9cpu,1,13)) * 0.000001                      01421611
  /* PDRT9CPU T9    mode Cpu     time     */                            01421711
  offs = offs+12                                                        01421811
  usrt9cpu = c2x(SUBSTR(INPUT_REC,offs,8))                              01421911
  usrt9cpu = x2d(SUBSTR(usrt9cpu,1,13)) * 0.000001                      01422011
                                                                        01422111
  /* response time */                                                   01422210
  resp=stopts-startts                                                   01422310
  if resp < 0 then                                                      01422410
  do                                                                    01422510
      resp=resp* (-1)                                                   01422610
  end                                                                   01423010
  /* sometimes start time is greater than stop time , swap values */    01423114
  if startt > stopt then                                                01423215
  do                                                                    01423314
      m=startt                                                          01423414
      startt=stopt                                                      01423514
      stopt =m                                                          01423614
  end                                                                   01423714
  /*          PDRDB2RC db2 requests */                                  01423814
  offs   = 2133                                                         01424013
  db2reqt  = c2d(SUBSTR(INPUT_REC,offs,4))                              01425011
  offs   = offs   + 4                                                   01426013
  mqreqt   = c2d(SUBSTR(INPUT_REC,offs,4))                              01440011
  Return                                                                02290000
                                                                        06800005
write_header:                                                           06801005
  say 'CSV file ' oufl     ' will be produced'                          06810000
  queue "Date,Sysid,Applid,Tran,userid,startt,stopt,Resp,CPU,",         06820014
        "DB2req,MQreq,",                                                06830014
        "UsrDisp,",                                                     06911014
        "UsrSusp, " ,                                                   06911114
        "UsrWait," ,                                                    06911214
        "usrQRdp, " ,                                                   06911314
        "usrQRcpu," ,                                                   06911414
        "usrOTdp ," ,                                                   06911514
        "usrOTcpu," ,                                                   06912014
        "usrROdp ," ,                                                   06913010
        "usrROcpu," ,                                                   06914010
        "usrK8dp ," ,                                                   06915014
        "usrK8cpu," ,                                                   06916014
        "usrK9dp ," ,                                                   06917014
        "usrK9cpu," ,                                                   06918014
        "usrL8cpu," ,                                                   06919014
        "usrL9cpu," ,                                                   06919114
        "usrS8cpu," ,                                                   06919214
        "usrX8cpu," ,                                                   06920014
        "usrX9cpu," ,                                                   06930014
        "usrT9cpu"                                                      06940014
                                                                        06950000
  "EXECIO" queued() "DISKW OUFL"                                        06951010
  return                                                                06952010
                                                                        06960010
write_report:                                                           06961010
    if startt < mintime then mintime=startt                             06970007
    if stopt  > maxtime then maxtime=stopt                              06970107
    totcpu=totcpu + usrcput                                             06970207
    totdb2r = totdb2r + db2reqt                                         06970307
    totelap=totelap+resp                                                06970409
    reco= reco+ 1                                                       06971007
    /*rows in excel format */                                           06980000
    queue tsdate   !! ',' !! sysid    !! ','  ,                         06990005
    !! applid   !! ','   ,                                              07000005
    !! Tranid       !! ','   ,                                          07010005
    !! userid       !! ','   ,                                          07020005
    !! '"' !! startt !! '"'           !! ','   ,                        07030016
    !! '"' !! stopt  !! '"'           !! ','   ,                        07031016
    !! resp             !! ','   ,                                      07050005
    !! usrcput           !! ','   ,                                     07060005
    !! db2reqt        !! ','   ,                                        07070010
    !! mqreqt         !! ','   ,                                        07080010
    !!  usrdisp     !! ','   ,                                          07090010
    !!  usrsusp     !! ','   ,                                          07160010
    !!  usrwt       !! ','   ,                                          07190010
    !!  usrqrdp     !! ','   ,                                          07220010
    !!  usrqrcpu    !! ','   ,                                          07250010
    !!  usrotdp     !! ','   ,                                          07280010
    !!  usrotcpu    !! ','   ,                                          07310010
    !!  usrROdp !! ','   ,                                              07330010
    !!  usrROcpu !! ','   ,                                             07370010
    !!  usrk8dp !! ','   ,                                              07382010
    !!  usrk8cpu !! ','   ,                                             07385010
    !!  usrk9dp !! ','   ,                                              07388010
    !!  usrk9cpu !! ','   ,                                             07389210
    !!  usrl8cpu !! ','   ,                                             07389510
    !!  usrl9cpu !! ','   ,                                             07389810
    !!  usrs8cpu !! ','   ,                                             07390110
    !!  usrx8cpu !! ','   ,                                             07390410
    !!  usrx9cpu !! ','   ,                                             07390710
    !!  usrt9cpu                                                        07391010
                                                                        07400010
   "EXECIO" queued() "DISKW OUFL"                                       07401010
return                                                                  07410000
stck:                                                                   07420000
Arg TUNITS                                                              07430000
  TIMESTAMP = Copies(0,26)  /* force result length=26 */                07440000
  Address linkpgm "BLSUXTOD TUNITS TIMESTAMP"                           07450000
  /* variable Timestamp has the value of timestamp */                   07460000
  TSDate=substr(timestamp,1,10)                                         07470000
  TSTime=substr(timestamp,12,15)                                        07480005
  hh=substr(tstime,1,2)                                                 07481105
  mm=substr(tstime,4,2)                                                 07482005
  ss=substr(tstime,7,2)                                                 07483005
  cc=substr(tstime,10,6)*0.000001                                       07484005
  tots=hh*3600+60*60+ss+cc                                              07485005
  return                                                                07490000


JCL :

//Your jobcard 
//* INPUT : &HLQ..SMFEXTS (EXTRACT SMF STATS ONLY)                      00030000
//*                          VOIR JOB EXTSMF                            00040000
//* X'64' = 100                                                         00050000
//*                                                                     00060000
// SET HLQ=SYSTMP.WSYNGUD                                               00070000
//*                                                                     00070200
//* REX110                                                              00120000
//* INPUT : &HLQ..REPORT.CICMOL                                         00130002
//* OUTPUT1: &HLQ..REPORT.TRAN                                          00140001
//* ARGUMENT 1 : PREFIX FOR DATASET NAME (HLQ VALUE)                    00160000
//REX110    EXEC PGM=IKJEFT01,DYNAMNBR=5,REGION=0M,COND=(4,LT),         00170003
//    PARM='REX110PE &HLQ'                                              00180002
//SYSEXEC  DD DISP=SHR,DSN=your_pds                                     00190000
//SYSTSPRT DD SYSOUT=*                                                  00200000
//SYSPRINT DD SYSOUT=*                                                  00210000
//SYSTSIN  DD DUMMY                                                     00220000
//                                                                      00230000


No comments:

Post a Comment