a >h@s2ddlZddlmZmZmZGdddeeZdS)N)Plugin PluginOpt UbuntuPluginc@sReZdZdZdZdZdZeddedded d ed ded d e ddgZ ddZ dS) CharmedMySQLa_ The Charmed MySQL plugin is used to collect MySQL configuration and logs from the Charmed MySQL snap package. It also collects MySQL Router and MySQL Shell configuration and logs where available, journal logs for the snap, and snap info. If the `dumpdbs` option is set to `True`, the plugin will also try and collect the names of the databases that the user has access to. The `mysql` user is used by default, but that can be set using the `dbuser` option. When using the `dumpdbs` option, you must then provide the password for the user using the `dbpass` option. z Charmed MySQLZ charmed_mysql)z charmed-mysqldbuserZmysqlz%Username for database dump collection)defaultZval_typeZdescdbpassz%Password for database dump collectiondumpdbsFzGet name of all databasesc sZd}d}tddtjD}|r(d}d}|d|d|d|d |d d }||d d |d dg||d |d|d|d|dg|s|d|d|drV|d}|d}dtjvr|s|j dtjd}n|s|j ddSd|i}d|}d|dgd} |jfdd | D|d!dS)"Nz/var/snap/charmed-mysql/commonz/var/snap/charmed-mysql/currentcss|]}d|vVqdS)Z KUBERNETESN).0keyr r D/usr/lib/python3.9/site-packages/sos/report/plugins/charmed_mysql.py 5z%CharmedMySQL.setup..r z /etc/mysqlz/var/log/mysqlz/etc/mysqlrouterz/var/log/mysqlrouterz/var/log/mysqlsh) MYSQL_CONF MYSQL_LOGSMYSQL_ROUTER_CONFMYSQL_ROUTER_LOGSMYSQL_SHELL_LOGSrz/*.pemz/*.keyrrrrzsnap.charmed-mysql.*zsnap info charmed-mysqlr rrZ MYSQL_PWDzWMYSQL_PWD present: Using MYSQL_PWD environment variable, user did not provide password.zHdumpdbs_error: option is set, but username and password are not providedz-h 127.0.0.1 -uzmysql z -e)z'show databases;'z,'select * from mysql.juju_units_operations;'zR'select * from performance_schema.replication_group_members order by MEMBER_HOST;'z$'show global status like "%conne%";'z.'select * from performance_schema.host_cache;'csg|]}d|qS) r )r queryZsql_cmdr r rz&CharmedMySQL.setup..)env) anyosenvironZadd_forbidden_pathZ add_copy_specZ add_journalZadd_cmd_outputZ get_optionZsosloginfoZwarning) selfZsnap_path_commonZsnap_path_currentZ k8s_deployZ conf_pathsZdb_userZdb_passZ mysql_envZoptsZqueriesr rrsetup/s^            zCharmedMySQL.setupN) __name__ __module__ __qualname____doc__Z short_descZ plugin_nameZpackagesrstrboolZ option_listr r r r rrs$ r)rZsos.report.pluginsrrrrr r r r s