Skip to content

Instantly share code, notes, and snippets.

@amr
Created February 28, 2010 22:25
Show Gist options
  • Save amr/317853 to your computer and use it in GitHub Desktop.
Save amr/317853 to your computer and use it in GitHub Desktop.
#!/bin/bash
SLEEP=1
THRESHOLD=500
while [ 1 ]
do
threads=`mysqladmin stat | awk '{ print $4 }'`
echo "Active threads: $threads"
if [ $threads -gt $THRESHOLD ]; then
log="/root/mysql-monitor/logs/sqls-$threads-`date +%s`.log"
echo "SHOW FULL PROCESSLIST" | mysql > $log
echo "Dumped the full processlist: $log"
fi
sleep $SLEEP
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment