Chinaunix首页 | 论坛 | 博客
  • 博客访问: 466660
  • 博文数量: 279
  • 博客积分: 4467
  • 博客等级: 上校
  • 技术积分: 2830
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-03 14:43
文章分类

全部博文(279)

文章存档

2013年(1)

2012年(39)

2011年(35)

2009年(29)

2008年(131)

2007年(44)

分类:

2008-06-13 16:41:54

8.       checkquerylog.pl -t "080502  7:54:20" -d "646656" -f "pattern match"
Description: check the query log for particular transaction with match datetime or mysql query id.
checkquerylog.pl -t "080502" -f "sku_no" to get an query id.
then
checkquerylog.pl -d "646656"
根据命令行选项来筛选mysqllog.
return result:
         646656 Connect     ws1@localhost on ws1
         646656 Query       set autocommit=0
         646656 Query       SET NAMES 'utf8'
         646656 Query       select map_id,target_tables_name,target_fields,src_tables_name,src_fields,src_columnnum,pri_key,default_value from database_field_map where map_id=84 and src_fields<>'' order by src_columnnum
         646656 Query       select map_id,target_tables_name,target_fields,src_tables_name,src_fields,src_columnnum,pri_key,default_value from database_field_map where map_id=84 and src_fields='' and default_value<>'' order by src_columnnum
         646656 Query       select  xf_storerkey, xf_sku, xf_desc, xf_brand, xf_manusku, xf_company, xf_seasonname, xf_maincat, xf_itemcode, xf_chidesc1, xf_chidesc2, xf_plu, xf_color, xf_size, xf_sizeseq from inbound_xf_towmsitemmas where (xf_storerkey='18328' ) and (status_flag=0 or status_flag=100) for update
         646656 Query       update inbound_xf_towmsitemmas set status_flag=100 where xf_storerkey='18328'
         646656 Query       select map_id,target_tables_name,target_fields,src_tables_name,src_fields,src_columnnum,pri_key,default_value from database_field_map where map_id=81 and src_fields<>'' order by src_columnnum
         646656 Query       select map_id,target_tables_name,target_fields,src_tables_name,src_fields,src_columnnum,pri_key,default_value from database_field_map where map_id=81 and src_fields='' and default_value<>'' order by src_columnnum
         646656 Query       select  xf_storerkey, xf_sku, xf_desc, xf_brand, xf_manusku, xf_company, xf_seasonname, xf_maincat, xf_itemcode, xf_chidesc1, xf_chidesc2, xf_plu, xf_color, xf_size, xf_sizeseq from inbound_xf_towmsitemmas where (xf_storerkey='11328' ) and (status_flag=0 or status_flag=100) for update
080502  7:54:16     646656 Query       update inbound_xf_towmsitemmas set status_flag=100 where xf_storerkey='11328'
080502  7:54:20     646656 Query       update inbound_xf_towmsitemmas set status_flag=1 where status_flag=100
080502  7:54:22     646656 Query       commit

#!/usr/bin/env perl


use strict;
use warnings;

use Options;

# Define the options supported

my $options = new Options(params => [
                        ['time', 't',"",'check log with time'],
                        ['id', 'd',"",'check log with id'],
                        ['match','f',"",'check log with pattern match'],
                        ],
                        flags => [
                        ['help', 'h', 'Display this usage guide.']
                        ]);

# Parse the default option source (@ARGV)

my %results = $options->get_options();

# Provide usage

if($options->get_result('help')){
    $options->print_usage();
    exit(1);
}
# It is also acceptable to access the results hash directly,

# but the following method is generally a better approach.

# See Options.pm POD docs for more info.

my $time = $options->get_result('time');
my $id = $options->get_result('id');
my $match = $options->get_result('match');
if($time){
 if($id){
   if($match){
      system "cat /var/log/mysqld.log|grep $time|grep $id|grep $match";
     print "\n";
    exit(1);
    }
    system "cat /var/log/mysqld.log|grep grep $time|grep $id";
    print "\n";
    exit(1);
     }
  system "cat /var/log/mysqld.log|grep $time";
  print "\n";
  exit(1);
}
if($id){
 if($match){
  system "cat /var/log/mysqld.log|grep $id|grep $match";
  print "\n";
 exit(1);
}
system "cat /var/log/mysqld.log|grep $id";
print "\n";
exit(1);
}
if($match){
system "cat /var/log/mysqld.log|grep $match";
print "\n";
exit(1);
}

阅读(189) | 评论(0) | 转发(0) |
0

上一篇:startwservices.pl

下一篇:Nagios远程监控软件

给主人留下些什么吧!~~