Skip to content

Instantly share code, notes, and snippets.

@hasanparasteh
Created September 21, 2022 14:39
Show Gist options
  • Save hasanparasteh/0e47a58184311c2bd29de1d740c7646e to your computer and use it in GitHub Desktop.
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
#/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