File: //lib/python3/dist-packages/sos/report/plugins/__pycache__/charmed_mysql.cpython-310.pyc
o
([Qh� � @ s2 d dl Z d dlmZmZmZ G dd� dee�ZdS )� N)�Plugin� PluginOpt�UbuntuPluginc @ sR e Zd ZdZdZdZdZeddedd�ed d
edd�edd
e dd�gZ
dd� ZdS )�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 MySQL�
charmed_mysql)z
charmed-mysql�dbuser�mysqlz%Username for database dump collection)�default�val_type�desc�dbpass� z%Password for database dump collection�dumpdbsFzGet name of all databasesc
sZ d}d}t dd� tjD ��}|rd}d}|� d�|� d�|� d�|� d �|� d
�d�}| �|d � d
�|d � d�g� | �|d |d |d |d |d g� |s\| �d� | �d� | �d�r�| �d�}| �d�}dtjv r~|s~| j� d� tjd }n
|s�| j�
d� d S d|i}d|� �}d|� d�� g d�} | j� fdd �| D �|d!� d S d S )"Nz/var/snap/charmed-mysql/commonz/var/snap/charmed-mysql/currentc s s � | ]}d |v V qdS )�
KUBERNETESN� )�.0�keyr r �B/usr/lib/python3/dist-packages/sos/report/plugins/charmed_mysql.py� <genexpr>5 s � z%CharmedMySQL.setup.<locals>.<genexpr>r
z
/etc/mysqlz/var/log/mysqlz/etc/mysqlrouterz/var/log/mysqlrouterz/var/log/mysqlsh)�
MYSQL_CONF�
MYSQL_LOGS�MYSQL_ROUTER_CONF�MYSQL_ROUTER_LOGS�MYSQL_SHELL_LOGSr z/*.pemz/*.keyr r r r zsnap.charmed-mysql.*zsnap info charmed-mysqlr r r � 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;'c s g | ] }� � d |� ��qS )� r )r �query��sql_cmdr r �
<listcomp>� s z&CharmedMySQL.setup.<locals>.<listcomp>)�env)�any�os�environ�add_forbidden_path�
add_copy_spec�add_journal�add_cmd_output�
get_option�soslog�info�warning)
�self�snap_path_common�snap_path_current�
k8s_deploy�
conf_paths�db_user�db_pass� mysql_env�opts�queriesr r r �setup/ s` � ��
��
��zCharmedMySQL.setupN)�__name__�
__module__�__qualname__�__doc__�
short_desc�plugin_name�packagesr �str�bool�option_listr6 r r r r r s&