分析OGG的trailfile中的表数据量

有时侯,我们需要分析一下GoldenGate抽取出来的trailfile里的相关数据量,当然直接用logdump的count命令就可以完成,但是格式就比较难看。
如果想要分析哪张表抽取的数据量最大,直接用logdump很难一下子定位出来。贡献个脚本,可以很方便地看到哪张表的数据量比较大。

$ cat analyze_trail.sh 
#!/bin/sh

####################################################
##
## Analyze OGG trail file OP count
##    
## Usage:
##   1.You must modify the variable in the file
##     GGHOME 
##   2.Call Method :  
##     /gg/analyze_trail.sh <trail_file_path>
##     for example: sh /gg/analyze_trail.sh /gg/dirdat/tt004277
## 
## PeiZhengfeng 2017.03.14
## hthorizion
##
## History
## 
## Platform for Unix/Linux
##
####################################################

GGHOME=/gg
TRAILFILE=$1

echo "detail on; open $1; count"| $GGHOME/logdump | awk '
BEGIN {printf "%-40s %-10s %-10s %-10s %-10s\n","Name                                    ","Delete    ", "Insert    ","FiledComp ","Total     ";
       printf "%-40s %-10s %-10s %-10s %-10s\n","----------------------------------------","----------", "----------","----------","----------";}

{
  while (match($1, /[^ ]+\.[^ ]+/)) {
    printf "%-40s ", $1
    
    vPrint = 0;
    vInsert = 0;
    vDelete = 0;
    vFieldComp = 0;
    for (i=1;i<=6;i++) {
      getline;
      if (match($1, /Insert/)) {
        vInsert = $2;
      }
      if (match($1, /Delete/)) {
        vDelete = $2;
      }
      if (match($1, /FieldComp/)) {
        vFieldComp = $2;
      }
      if (match($0, /^$/)) {
        printf "%-10s %-10s %-10s %-10s\n", vDelete, vInsert, vFieldComp, vDelete+vInsert+vFieldComp;
        vPrint = 1;
        break;
      }
    }
    if (vPrint == 0) {
      printf "%-10s %-10s %-10s %-10s\n", vDelete, vInsert, vFieldComp, vDelete+vInsert+vFieldComp;
    }
    
  }
}'

使用方法如下:

$ sh analyze_trail.sh ./dirdat/ly001839
Name                                     Delete     Insert     FiledComp  Total     
---------------------------------------- ---------- ---------- ---------- ----------
xxxxxx.BSE_CHANNEL                       0          18         125        143       
xxxxxx.BSE_CHANNEL_CBLSECT               82         143        56         281       
xxxxxx.BSE_EQP_FACE                      0          36         0          36        
xxxxxx.BSE_EQUIPMENT                     0          18         4          22        
xxxxxx.BSE_HOLE                          0          1          0          1         
xxxxxx.BSE_PIPE_HOLE                     0          4          67         71        
xxxxxx.BSE_PIPE_SECT                     0          4          0          4         
xxxxxx.BSE_POLE                          0          16         0          16        
xxxxxx.BSE_SECTION                       0          18         0          18        
xxxxxx.BSE_SUB_WIRE                      0          12         0          12        
xxxxxx.BSE_WIRE_SECT                     0          12         0          12        

还可以进行sort排序

$ sh analyze_trail.sh ./dirdat/ly001839 | sort -n -k 5
---------------------------------------- ---------- ---------- ---------- ----------
Name                                     Delete     Insert     FiledComp  Total     
......
xxxxxx.PHY_TERM_PORT                     2835       2822       29536      35193     
xxxxxx.SRV_B2O_BUSI_ORDER                12971      14085      13563      40619     
xxxxxx.SRV_RES_ORDER                     3850       4383       33846      42079     
xxxxxx.SRV_RES_ORDER_2_STATE             23610      25547      257        49414     
xxxxxx.SRV_WORK_ORDER_2_STATE            23197      26687      189        50073     
xxxxxx.SRV_RO_2_RES                      23740      26275      2112       52127     
xxxxxx.SRV_WORK_ORDER                    7244       8697       51871      67812     
xxxxxx.SRV_PSO_PROPERTY                  37050      42279      226        79555     
xxxxxx.SRV_RO_2_ABILITY                  52195      54551      0          106746    

关于紫砂壶

感悟技术人生
此条目发表在GoldenGate, 工具分类目录,贴了标签。将固定链接加入收藏夹。