Created
December 20, 2016 03:13
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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