MySQL Shell Plugins: check

This blog was initially referring to the audit plugin, but I renamed it as check plugin to be more compatible with all the current and future methods included in it.

As you may know, it’s now possible to create your own plugins for MySQL Shell. See the following posts:

I’ve created several plugins that you can find on github. My colleague Bernt already contributed too.

You are more than welcome to comment, fill bugs, feature requests and pull requests of course !

I want to start a series of article covering those plugins. Their goal and how to use them.

Check Plugin

I will start today with the check one and particularly the methods/functions related to the binary logs.

Let’s first see the help of that plugin:

getBinlogs()

Let’s see an example of the execution of that method:

So on my server we can see that currently we have 9 binlog files available.

getBinlogsIO()

This method prints the IO statistics of binary logs files available on the server:

Let’s run show binlog events in 'binlog.000052'; and see the new output:

showTrxSize() and showTrxSizeSort()

And finally, let’s verify the size of transactions in the binary logs. We have two methods, one showing the transactions from the end to the start of the last binary log or the one provided as argument. The other one sort them by size descending and limit it to 10 by default:

Let’s see the last one in action:

This is a good way to see if your don’t have transaction size bigger than group_replication_transaction_size_limit when you want to migrate to MySQL InnoDB Cluster.

In the next post, I will cover the remaining methods of the check plugin.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

9 Comments

  1. Tried to install this but getting
    WARNING: Found errors loading plugins, for more details look at the log at: /home/mysql/.mysqlsh/mysqlsh.log

    And in there
    2019-11-20 16:51:39: Error: Error loading Python file ‘/home/mysql/.mysqlsh/plugins/ext/audit/init.py’:
    Execution failed:
    Traceback (most recent call last):
    File “init.py”, line 1, in
    ImportError: No module named mysqlsh_plugins_common

    So it seems like a bootstrapping problem in that the plugins need mysqlsh_plugins_common, but how/where is mysqlsh_plugins_common supposed to be found?

      • mysql-shell-commercial-8.0.17-1.1.el7.x86_64

        I wasn’t exactly clear on how to extract things. This is how I have it currently.
        /home/mysql/.mysqlsh/plugins
        /home/mysql/.mysqlsh/plugins/ext
        /home/mysql/.mysqlsh/plugins/ext/audit
        /home/mysql/.mysqlsh/plugins/ext/audit/__init__.py
        /home/mysql/.mysqlsh/plugins/ext/audit/init.py
        /home/mysql/.mysqlsh/plugins/ext/audit/queries.py
        /home/mysql/.mysqlsh/plugins/ext/audit/trx.py
        /home/mysql/.mysqlsh/plugins/ext/__init__.pyc
        /home/mysql/.mysqlsh/plugins/mysqlsh_plugins_common.py

    • I was able to bootstrap it by creating this file
      cat /home/mysql/.mysqlsh/mysqlshrc.py
      sys.path.append(‘/home/mysql/.mysqlsh/plugins/ext’)

      and then making sure mysqlsh_plugins_common.py and extracted files are stored like this
      /home/mysql/.mysqlsh/plugins/ext/audit
      /home/mysql/.mysqlsh/plugins/ext/audit/__init__.py
      /home/mysql/.mysqlsh/plugins/ext/audit/init.py
      /home/mysql/.mysqlsh/plugins/ext/audit/queries.py
      /home/mysql/.mysqlsh/plugins/ext/audit/trx.py
      /home/mysql/.mysqlsh/plugins/ext/audit/__init__.pyc
      /home/mysql/.mysqlsh/plugins/ext/audit/trx.pyc
      /home/mysql/.mysqlsh/plugins/ext/audit/queries.pyc
      /home/mysql/.mysqlsh/plugins/ext/mysqlsh_plugins_common.py

        • Yes, I’m logged in as mysql. If you want to compare your sys.path to mine, here it is.
          MySQL localhost+ ssl Py > sys.path
          [
          “/usr/share/mysqlsh/oci_sdk/pytz-2019.1-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/python_dateutil-2.8.0-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/pyasn1-0.4.5-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/paramiko-2.4.2-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/oci-2.2.13-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/cryptography-2.7-py2.7-linux-x86_64.egg”,
          “/usr/share/mysqlsh/oci_sdk/configparser-3.7.4-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/cffi-1.12.3-py2.7-linux-x86_64.egg”,
          “/usr/share/mysqlsh/oci_sdk/certifi-2019.3.9-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/bcrypt-3.1.6-py2.7-linux-x86_64.egg”,
          “/usr/share/mysqlsh/oci_sdk/PyNaCl-1.3.0-py2.7-linux-x86_64.egg”,
          “/usr/share/mysqlsh/oci_sdk/six-1.12.0-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/pyOpenSSL-19.0.0-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/ipaddress-1.0.22-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/enum34-1.1.6-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk/asn1crypto-0.24.0-py2.7.egg”,
          “/usr/share/mysqlsh/oci_sdk”,
          “/usr/lib64/python27.zip”,
          “/usr/lib64/python2.7”,
          “/usr/lib64/python2.7/plat-linux2”,
          “/usr/lib64/python2.7/lib-tk”,
          “/usr/lib64/python2.7/lib-old”,
          “/usr/lib64/python2.7/lib-dynload”,
          “/usr/lib64/python2.7/site-packages”,
          “/usr/lib/python2.7/site-packages”,
          “/home/mysql/.mysqlsh/plugins/ext”
          ]
          Perhaps mysqlsh_plugins_common is in one of the /usr/share/mysqlsh/oci_sdk locations for you.

          • Thx for the info.. no it’s not there and my sys.path is the following:
            Py  sys.path
            [
            “/usr/share/mysqlsh/oci_sdk/oci-2.5.2-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/asn1crypto-1.0.0-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/six-1.12.0-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/pytz-2019.2-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/python_dateutil-2.8.0-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/pyasn1-0.4.7-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/pyOpenSSL-19.0.0-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/paramiko-2.4.2-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/cryptography-2.7-py3.7-linux-x86_64.egg”,
            “/usr/share/mysqlsh/oci_sdk/configparser-4.0.2-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/configparser-3.8.1-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/cffi-1.12.3-py3.7-linux-x86_64.egg”,
            “/usr/share/mysqlsh/oci_sdk/certifi-2019.9.11-py3.7.egg”,
            “/usr/share/mysqlsh/oci_sdk/bcrypt-3.1.7-py3.7-linux-x86_64.egg”,
            “/usr/share/mysqlsh/oci_sdk/PyNaCl-1.3.0-py3.7-linux-x86_64.egg”,
            “/usr/share/mysqlsh/oci_sdk”,
            “/usr/lib64/python37.zip”,
            “/usr/lib64/python3.7”,
            “/usr/lib64/python3.7/lib-dynload”,
            “/usr/local/lib/python3.7/site-packages”,
            “/usr/lib64/python3.7/site-packages”,
            “/usr/lib/python3.7/site-packages”
            ]

Leave a Reply

Your email address will not be published. Required fields are marked *

As MySQL Community Manager, I am an employee of Oracle and the views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

You can find articles I wrote on Oracle’s blog.