Ever wanted to just look at QPS in real time while logged into your server?
Well here’s a little command line hackery to do it quick and dirty.
[user@yourserver ~] $ LASTVAL=0; while true; do CURVAL=`mysql --batch -N -e "show status like 'Quer%';" | awk '{print $2}'`; QPS=`expr $CURVAL - $LASTVAL`; if [ $LASTVAL -ne 0 ]; then echo "$CURVAL $QPS"; fi; LASTVAL=$CURVAL; sleep 1; done
The output looks like this:
65549603430 2439 65549605421 1991 65549606912 1491 65549611219 4307 65549614186 2967 65549618048 3862 65549620853 2805
The first column is just the Query counter value. The second column is the QPS.
This script requires a .my.cnf to exist in your home directory (or that you do something nastily insecure and supply -u user -ppassword to the mysql command in the example above).