Skip to content

Instantly share code, notes, and snippets.

@bessangel
Created June 16, 2011 16:19
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bessangel/1029610 to your computer and use it in GitHub Desktop.
Save bessangel/1029610 to your computer and use it in GitHub Desktop.
mtop.sh - mysql top
#!/bin/bash
if [ ! -z $1 ]; then
export MTOPU="-uroot"
export MTOPPW="-p$1"
fi
if [ -f /root/.my.cnf ]; then
MTOPU=' '
MTOPPW=' '
fi
if [ -z $MTOPU ] && [ -z $MTOPPW] && [ $MTOPU != ' ' ]; then
echo "User/Password!!"
read -p 'user:' us
read -s -p 'pw:' pw
export MTOPU="-u${us}"
export MTOPPW="-p${pw}"
# exit;
fi
clear;
watch "top -b | head; mysqladmin -u $MTOPU -p$MTOPPW status;echo; mysqladmin $MTOPU $MTOPPW processlist | head -20"
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment