OneAgent MySQL plugin

Gathers stats from a given MySQL server instance. The stats are selected values from 2 queries:

ruxit_MySQLdb module is used to access the MySQL instance. It is based on mysql-ctypes - ported to work with python 3 and using bundled libmariadb instead of libmysql as the underlying C library. To avoid confusion the package is distributed under a unique name with ruxit_ prefix.

Running the plugin requires specifying user credentials and server port in the configuration.

This is a singleton type plugin - one instance will be created even if multiple MySQL process groups instances are detected.

The plugin can only query one MySQL server due to limitations of ruxit plugin configuration mechanism. In case of multiple MySQL server running on a one host, the one monitored will the one listening on port specified in the configuration.

class ruxit_mysql.MySqlPlugin(**kwargs)[source]

Bases: ruxit.api.base_plugin.BasePlugin

MySQL plugin class. This plugin is stateful - initialize and close methods are defined in order to maintain one server connection for the lifetime of the plugin.

Class fields mirror measurements declared in the plugin.json and declare some few parameters i.e: connection timeout, error codes

__init__ should not be overridden without a call to super.

Parameters:
  • config (Dict[str, str]) -- plugin configuration
  • results_builder (ResultsBuilder) -- instance for this plugin,
  • json_config -- parsed plugin.json contents,
  • plugin_info (PluginInfo) -- json data of the plugin exposed in a more convenient way,
  • associated_entity -- monitored entity associated with the plugin, if any (deprecated).
  • activation_context -- activation context for the plugin,
  • process_snapshot (ProcessSnapshot) -- latest available at method call,
  • entity_resolver (EntityResolver) -- exposes additional methods for querying snapshot
  • logger -- plugin specific logger for plugin development, set to None only in unit tests
initialize(**kwargs)[source]

Initializes the mysql plugin.

This parses the configuration of the plugin and initiates a connection object so that every query does not need to establish a new connection.

The connection is established over tcp by specifying 127.0.0.1 as connection address. Using localhost would cause the connection to be made via unix sockets which would require additional discovery of the socket. Note that this is the limitation of the C connector library and other package can behave differently.

Raises:
query(**kwargs)[source]

Gathers the mysql data from global status and global variables queries.

The measurements use a ruxit.api.selectors.ListenPortSelector to associate data with correct entity id (the mysql server process group) in case of multiple MySQL instances running on a host.

Raises:
close(**kwargs)[source]