-
-
Save vicentedeandrade/2e697cfe3102f8d3c3981e461f663ef6 to your computer and use it in GitHub Desktop.
SQL `watch` commands
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
watch -t -n 5 'echo -e "THREAT BOARD\n`date`\n\n TOP\n---------------------";top -b -n 1 | head -12 | tail -6; echo -e " \n df -h\n---------------------"; df -h | sort -g -k5; echo -e " \n free -m\n---------------------"; free -m; echo -e " \n MySQL\n---------------------"; mysql -e "SELECT COUNT(ID) AS \`NUMBER OF THREADS\` FROM INFORMATION_SCHEMA.PROCESSLIST;" | sed "$!{:a;N;s/\n/: /;ta}"; mysql -t -e "SELECT ID, USER, HOST, DB, STATE, COMMAND, TIME, SUBSTRING(INFO, 0, 20) AS QUERY FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY TIME DESC;";' |
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
watch -t -n 10 'mysql -t -e "SELECT ID, USER, HOST, DB, STATE, TIME FROM INFORMATION_SCHEMA.PROCESSLIST where TIME > 10 AND COMMAND != \"Sleep\" AND DB != \"eximstats\" ORDER BY TIME;"' | |
watch -t -n 5 'mysql -t -e "SELECT ID, USER, HOST, DB, STATE, TIME, SUBSTRING(INFO, 0, 20) FROM INFORMATION_SCHEMA.PROCESSLIST where TIME > 2 AND COMMAND != \"Sleep\" AND DB != \"eximstats\" ORDER BY TIME;"' | |
watch -t -n .5 'mysql -t -e "SELECT ID, USER, HOST, DB, STATE, TIME, SUBSTRING(INFO, 0, 20) AS QUERY FROM INFORMATION_SCHEMA.PROCESSLIST WHERE DB != \"eximstats\" ORDER BY TIME DESC;"' | |
watch -t -n 5 'echo -e "\nTHREAT BOARD\n`date`\n\n"; mysql -t -e "SELECT ID, USER, HOST, DB, STATE, TIME, SUBSTRING(INFO, 0, 20) AS QUERY FROM INFORMATION_SCHEMA.PROCESSLIST where TIME > 2 AND COMMAND != \"Sleep\" AND DB != \"eximstats\" ORDER BY TIME;"' | |
watch -t -n 5 'echo -e "\nTHREAT BOARD\n`date`\n\n\n\nTOP\n---------------------\n";top -b -n 1 | head -12; echo -e " \n\n\nMySQL\n---------------------\n"; mysql -t -e "SELECT ID, USER, HOST, DB, STATE, COMMAND, TIME, SUBSTRING(INFO, 0, 20) AS QUERY FROM INFORMATION_SCHEMA.PROCESSLIST where TIME > 0 AND DB != \"eximstats\" ORDER BY TIME;";' | |
watch -t -n 5 'echo -e "\nTHREAT BOARD\n`date`\n\n\n\n TOP\n---------------------\n";top -b -n 1 | head -12; echo -e " \n\n\n MySQL\n---------------------\n"; mysql -t -e "SELECT ID, USER, HOST, DB, STATE, COMMAND, TIME, SUBSTRING(INFO, 0, 20) AS QUERY FROM INFORMATION_SCHEMA.PROCESSLIST ORDER BY TIME DESC;";' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment