zoukankan      html  css  js  c++  java
  • perl binlog dml操作报告

    <pre name="code" class="html">if ( $#ARGV < 2 ){  
            print "please input  like  binglog-0001 '2013-07-01 00:00:00' '2013-07-02 00:00:00'!
    ";
                    exit(-1);  
                       } 
            $file= $ARGV[0];  
            $start_dt = $ARGV[1];
            $end_dt = $ARGV[2];
    @bin=`mysqlbinlog --start-datetime='$start_dt' --stop-datetime='$end_dt' $file`;
           foreach  (@bin){
            $_ =~ s/`//g;
    #s+匹配一个或者多个空格
           if ($_ =~/^updates+(.*?)s+/i)
             {#print "$1 is $1
    ";
             $act='update';
             $table=$1;
             $var=$act.-$table;
             $hash1{$var}++;
             }
            
      if ($_ =~/^deletes+froms+(.*?)s+/i)
             {#print "$1 is $1
    ";
             $act='delete';
             $table=$1;
             $var=$act.-$table;
             $hash2{$var}++;
             }
    
    
      if ($_ =~/^inserts+intos+(.*?)s+/i)
             {#print "$1 is $1
    ";
             $act='insert';
             $table=$1;
             $var=$act.-$table;
             $hash3{$var}++;
             }
    
    
    };
    
      while(my($tj, $times) = each %hash1) {
     print "$tj  count(*) ==   $times
    ";
    };
    
      while(my($tj, $times) = each %hash2) {
     print "$tj  count(*) ==   $times
    ";
    };
    
      while(my($tj, $times) = each %hash3) {
    
     print "$tj  count(*) ==   $times
    ";
    
    };
    
    [root@zjzc01 binlog]# perl perl_binlog.pl  mysql-bin.000086 '2016-08-26 00:00:00' '2016-08-27 00:00:00'
    update-QRTZ_CRON_TRIGGERS  count(*) ==   59
    update-QRTZ_FIRED_TRIGGERS  count(*) ==   59
    update-ClientActionTrack  count(*) ==   19
    update-QRTZ_TRIGGERS  count(*) ==   132
    update-QRTZ_SCHEDULER_STATE  count(*) ==   323
    delete-QRTZ_FIRED_TRIGGERS  count(*) ==   58
    insert-ClientActionTrack(  count(*) ==   19
    insert-QRTZ_FIRED_TRIGGERS  count(*) ==   55


    
                                        
    
  • 相关阅读:
    C#基础知识之GC 垃圾回收
    获取地址栏参数并转化为对象
    input type属性为number时,去掉右边的上下箭头
    vscode用服务打开html
    富文本的原理和插件使用
    原生js拖拽、jQuery拖拽、vue自定义指令拖拽
    js的call()方法
    js继承
    网页禁止复制和解除禁止复制
    ES6-解构赋值
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350352.html
Copyright © 2011-2022 走看看