Created
June 21, 2017 15:35
-
-
Save vmanyushin/58e58a395c921d71ee56b5ac431f056d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#this script used monitor mysql network traffic.echo sql | |
tcpdump -i eno1 -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.=" $_"; | |
} | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source https://web.liferay.com/web/david.zhang/blog/-/blogs/how-to-catch-mysql-sql-with-tcpdump-in-linux