File: //lib/python3.6/site-packages/sos/report/plugins/__pycache__/charmed_mysql.cpython-36.pyc
3
\��h� � @ 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 MySQLZ
charmed_mysql�
charmed-mysql�dbuserZmysqlz%Username for database dump collection)�defaultZval_typeZdesc�dbpass� z%Password for database dump collection�dumpdbsFzGet name of all databasesc
sd d}d}t dd� tjD ��}|r(d}d}|� d�|� d�|� d�|� d �|� d
�d�}| j|d � d
�|d � d�g� | j|d |d |d |d |d g� |s�| jd� | jd� | jd��r`| jd�}| jd�}dtjko�| �r| jj d� tjd }n|�s| jj
d� d S d|i}d|� �}d|� d�� ddd d!d"g} | j� fd#d$�| D �|d%� d S )&Nz/var/snap/charmed-mysql/commonz/var/snap/charmed-mysql/currentc s s | ]}d |kV qdS )Z
KUBERNETESN� )�.0�keyr r �#/usr/lib/python3.6/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 Z 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 -ez'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
Zquery)�sql_cmdr r �
<listcomp>� s z&CharmedMySQL.setup.<locals>.<listcomp>)�env)�any�os�environZadd_forbidden_pathZ
add_copy_specZadd_journalZadd_cmd_outputZ
get_optionZsoslog�infoZwarning)
�selfZsnap_path_commonZsnap_path_currentZ
k8s_deployZ
conf_pathsZdb_userZdb_passZ mysql_envZoptsZqueriesr )r r �setup/ sZ
zCharmedMySQL.setupN)r )�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZpackagesr �str�boolZoption_listr r r r r r s
r )r Zsos.report.pluginsr r r r r r r r �<module> s