Skip to content

Instantly share code, notes, and snippets.

@nicka101
Created December 20, 2016 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicka101/56eee7a5088361bd1d3211d6d4b8cf67 to your computer and use it in GitHub Desktop.
Save nicka101/56eee7a5088361bd1d3211d6d4b8cf67 to your computer and use it in GitHub Desktop.
A simple bash script top-like program for mysql based on mysqladmin and dialog (well stty too, but its part of coreutils)
#!/bin/bash
# Top-like script for MySQL
DELAY=2
TTY_WIDTH=$(($(stty size | awk '{print $2}')-6)) # determine terminal width
TTY_HEIGHT=$(($(stty size | awk '{print $1}')-6)) # determine terminal height
while true; do
content="Status:\n"
content="$content$(mysqladmin status)\n"
content="${content}\nActive Queries:\n$(mysqladmin processlist)"
dialog --backtitle "MySQL top" --no-collapse --cr-wrap --infobox "$content" $TTY_HEIGHT $TTY_WIDTH
sleep $DELAY
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment