美文网首页
利用shell脚本抓取执行的sql语句

利用shell脚本抓取执行的sql语句

作者: 日风和 | 来源:发表于2016-01-14 17:14 被阅读393次
   #!/bin/bash
   #this script used montor mysql network traffic.echo sql
   tcpdump -i eth0 -s 0 -l -w - dst port 3306 | strings | perl -e '
   while(<>) { chomp; next if /^[^ ]+[ ]*$/;
   if(/^(SELECT|UPDATE|DELETE|INSERT|SET|COMMIT|ROLLBACK|CREATE|DROP|ALTER|CALL)/i)
   {
       if (defined $q) { print "$q\n"; }
           $q=$_;
       } else {
           $_ =~ s/^[ \t]+//; $q.=" $_";
       }
   }

相关文章

网友评论

      本文标题:利用shell脚本抓取执行的sql语句

      本文链接:https://www.haomeiwen.com/subject/iqiphttx.html