1

Is there a way to take the output from mysqlshell and use it in a script or similar.

I have set up a basic cluster for testing (3 x MySQL 8.0.27 databases, running on Debian 11).

I am now trying to find a way to capture the output from mysqlshell's cluster.status() output.

As an example, from inside mysqlshell I can run:

cluster=dba.getCluster()
cluster.status().defaultReplicaSet.topology['test-1:3306'].replicationLag

to get the current replication lag. I would like to capture that so it can be monitored automatically.

I assumed most of these statistics would also exist in the performance_schema or mysql_innodb_cluster_metadata databases somewhere, but I can't see them.

Is there a way to do this?

IGGt
  • 1,855
  • 3
  • 21
  • 39

1 Answers1

1

You can use Shell's command line integration to access the AdminAPI without entering Shell's interactive interface. That allows you to run the commands in a bash script for example or integrate it with other automation/monitoring tools.

https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-command-line-integration.html