Differences

This shows you the differences between two versions of the page.

Link to this comparison view

mysql:scripts [2008/11/21 18:01]
a
mysql:scripts [2009/05/25 00:35]
Line 1: Line 1:
-===== Kill every MySQL SELECT older than X seconds ===== 
-<code bash|f kill.sh> 
-#!/bin/bash 
-SEC=$1 
-IFS=’|’ 
-if [[ $SEC -lt 1 ]]; then 
-   echo “Usage: $0 SECONDS” 
-   exit 1 
-fi 
-mysqladmin proc -v|grep Query|grep -Evi “delete|update|insert|alter table” |while read dummy qid qusr qhost qdb qstat qsec qstat2 query 
-do 
-   if [ $qsec -gt $SEC ]; then 
-      echo “Killing query $qid…” 
-      mysqladmin kill $qid 
-   fi 
-done 
-</code> 
- 
-===== Sniff the MySQL traffic on the fly ===== 
-<code cli> 
-# 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)/i) { 
-    if (defined $q) { print "$q\n"; } 
-    $q=$_; 
-  } else { 
-    $_ =~ s/^[ \t]+//; $q.=" $_"; 
-  } 
-}' 
-</code> 
- 
- 
  
mysql/scripts.txt · Last modified: 2009/05/25 00:35 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready