Created
September 21, 2022 14:39
-
-
Save hasanparasteh/0e47a58184311c2bd29de1d740c7646e to your computer and use it in GitHub Desktop.
InnoDB MYSQL Monitoring Using MysqlShell. You just need to install `jq` and `mysql-shell` and save passwords only for first time
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
#/bin/sh | |
now=$(date +"%T") | |
servers=(server1 server2 server3) | |
selectedServer=${servers[ $RANDOM % ${#servers[@]} ]} | |
echo "Randmoly Selected $selectedServer for getting information..." | |
echo "Conntecting to the server..." | |
output=`mysqlsh root@$selectedServer:3306 -- clusterset status --extended true` | |
echo $output | | |
jq '.clusters' | | |
jq -r '.[]' | | |
jq '.topology[]' | | |
jq -r '"\(.address)\t\(.status)\t\(.memberRole)\t\(.shellConnectError)"' | | |
column -ts $'\t' | | |
awk -F, 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' > index.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment