
    ([Qh                     8    d dl Z d dlmZmZmZ  G d dee      Zy)    N)Plugin	PluginOptUbuntuPluginc                   h    e Zd ZdZdZdZdZ edded       ed	d
ed       edde	d      gZ
d Zy)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dumpdbsFzGet name of all databasesc                    d}d}t        d t        j                  D              }|rd}d}| d| d| d| d| d	d
}| j                  |d    d|d    dg       | j	                  |d   |d   |d   |d   |d   g       |s"| j                  d       | j                  d       | j                  d      r| j                  d      }| j                  d      }dt        j                  v r1|s/| j                  j                  d       t        j                  d   }n|s| j                  j                  d       y d|i}d| }d| d}	g d}
| j                  |
D cg c]	  }|	 d|  c}|       y y c c}w ) Nz/var/snap/charmed-mysql/commonz/var/snap/charmed-mysql/currentc              3   $   K   | ]  }d |v  
 yw)
KUBERNETESN ).0keys     B/usr/lib/python3/dist-packages/sos/report/plugins/charmed_mysql.py	<genexpr>z%CharmedMySQL.setup.<locals>.<genexpr>5   s     C,Cs   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   zsnap.charmed-mysql.*zsnap 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 -uzmysql 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;' )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sql_cmdqueriesquerys               r   setupzCharmedMySQL.setup/   s   ;= C

CC
 ! " //z:-.n=$5#66F!G$4#55I!J#3"44D E

 	,'(/,'(/!
 	 	|$|$*+*+)*
 	 34  9: ??9%ooh/Gooh/G bjj(  5 **[1##' $g.I$WI.DtfC(GG( 3:;%G9AeW%;   W &X <s    E9N)__name__
__module____qualname____doc__
short_descplugin_namepackagesr   strbooloption_listr8   r       r   r   r      sa     !J!K!H 	g8	
 	b38	
 	ut,	
K_rC   r   )r"   sos.report.pluginsr   r   r   r   r   rC   r   <module>rE      s     
 > >@6< @rC   