Created
February 27, 2017 18:43
-
-
Save rhemz/1c6912987398dc203461293dcacba98f to your computer and use it in GitHub Desktop.
poll mysql processlist, output to csv
This file contains 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
while sleep 5; do mysql -u dbuser -p$MYSQLPW -e "SELECT HOST, COMMAND, TIME, STATE, SUBSTRING(INFO, 1, 100) AS INFO, ROWS_SENT, ROWS_EXAMINED FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY HOST, TIME DESC INTO OUTFILE '//path/to/dir/mysqlproclist_$(date +%s).csv' FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n'"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment