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); }
|
阅读(220) | 评论(0) | 转发(0) |