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


    
                                        
    
  • 相关阅读:
    long类型和int类型的区别!!!!!
    Java-冒号的作用
    Java Scanner类
    jre安装过程
    76. 最小覆盖子串
    75. 颜色分类
    73. 矩阵置零
    72. 编辑距离
    71. 简化路径
    61. 旋转链表
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13350352.html
Copyright © 2011-2022 走看看