+
    Û1jî&  ã                   óN   € ^ RI t ^ RIt^ RIHtHtHt ^ RIHt  ! R R]]4      tR# )é    N)ÚPluginÚ	PluginOptÚUbuntuPlugin)Úis_executablec            
       óò   a € ] tR t^t o RtRtRt. R+OtRtRt	Rt
RtRtR	R
RRRRRRRR/t]! RR]RR7      ]! RR]RR7      ]! RR]RR7      ]! RR]RR7      .tR  tR! tR" tR# tR$ tR% tR& tR' tR( tR)tV tR*# ),ÚCharmedMySQLaq  
The Charmed MySQL plugin is used to collect MySQL configuration and logs
from the Charmed MySQL snap package or K8s deployment.
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 or the `MYSQL_PWD`
environment variable.
zCharmed MySQLÚcharmed_mysqlzcharmed-mysqlz/var/snap/charmed-mysql/commonz/var/snap/charmed-mysql/currentÚkubectlz app.kubernetes.io/name=mysql-k8sÚ
MYSQL_CONFz
/etc/mysqlÚ
MYSQL_LOGSz/var/log/mysqlÚMYSQL_ROUTER_CONFz/etc/mysqlrouterÚMYSQL_ROUTER_LOGSz/var/log/mysqlrouterÚMYSQL_SHELL_LOGSz/var/log/mysqlshÚdbuserÚmysqlz%Username for database dump collection)ÚdefaultÚval_typeÚdescÚdbpassÚ z%Password for database dump collectionÚdumpdbsFzGet name of all databasesÚ
logs_sinceÚ48hz9How far back to fetch logs with kubectl --since, K8s onlyc                ó:  € V P                  R 4      pV P                  R4      pR\        P                  9   d>   V'       g6   V P                  P	                  R4       \        P                  R,          pW3# V'       g   V P                  P                  R4       R# W3# )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 provided)NN)Ú
get_optionÚosÚenvironÚsoslogÚinfoÚwarning)ÚselfÚdb_userÚdb_passs   &  ÚB/usr/lib/python3/dist-packages/sos/report/plugins/charmed_mysql.pyÚ_get_db_credentialsÚ CharmedMySQL._get_db_credentials[   s‹   € Ø—/‘/ (Ó+ˆØ—/‘/ (Ó+ˆàœ"Ÿ*™*Ô$¯WØ�K‰K×Ñð1ôô —j‘j Õ-ˆGð ÐÐ÷ Ø�K‰K×Ñð#ôð ÐàÐÐó    c                óæ   € V P                  V P                   R V P                   R24      pVR,          ^ 8X  d8   \        \	        VR,          P                  4       P                  4       4      4      # . # )z get pods -A -l z- -o jsonpath='{.items[*].metadata.namespace}'ÚstatusÚoutput)Úexec_cmdÚkube_cmdÚselectorÚlistÚsetÚstripÚsplit)r"   Ú
namespacess   & r%   Ú_determine_namespacesÚ"CharmedMySQL._determine_namespacesn   si   € Ø—]‘]Ø�}‰}ˆoÐ-¨d¯m©m¨_ð =;ð ;ó
ˆ
ð �hÕ 1Ô$Üœ˜J xÕ0×6Ñ6Ó8×>Ñ>Ó@ÓAÓBÐBØˆ	r(   c                óÈ   € V P                  V P                   R V RV P                   R24      pVR,          ^ 8X  d&   VR,          P                  4       P	                  4       # . # )ú -n z get pods -l z( -o jsonpath='{.items[*].metadata.name}'r*   r+   )r,   r-   r.   r1   r2   )r"   Ú	namespaceÚpodss   && r%   Ú_get_pod_namesÚCharmedMySQL._get_pod_namesw   sc   € Ø�}‰}Ø�}‰}ˆo˜T ) ¨M¸$¿-¹-¸ð I6ð 6ó
ˆð ��>˜QÔØ˜•>×'Ñ'Ó)×/Ñ/Ó1Ð1Øˆ	r(   c                ó  € V P                    R V 2pV P                  V RV P                   R2V RV P                   2.4       V P                  V RV P                   RV R24       RpV P                  V4      pV P	                  4       pV P
                  P                  4        FU  w  rxV FJ  p	\        P                  ! V RV	 RV 2R	R
7       V RV RV	 RV RV RV	 RV 2p
V P                  V
4       KL  	  KW  	  V P                  V R2V R2.4       V P                  R4      '       Ed0   V P                  4       w  r¼V'       d	   V'       g   R# RV 2pRV R2pRP                  R V P                   4       4      p\        P                   ! 4       ;_uu_ 4       pRpVR,           V,           p\#        VRRR7      ;_uu_ 4       pVP%                  V4       RRR4       V Fn  p	V RV RV	 RV 2pV P                  V4       V RV RV RV	 RV 2	p
V P                  V
4       V RV RV	 RV RV RV RV 2pV P                  VV	 R 2R!7       Kp  	  RRR4       R# R#   + '       g   i     L�; i  + '       g   i     R# ; i)"r7   z get all -l z -o widez describe pods -l z	 logs -l z	 --since=z* --all-containers=true --prefix --all-podsr   Ú/T)Úexist_okz cp -c Ú Ú:z/*/MYSQL_CONF/*.pemz/*/MYSQL_CONF/*.keyr   Nú-h 127.0.0.1 -uúmysql ú -ec              3   óF   "  € T F  pVP                  R R4      x € K  	  R# 5i)Ú"z\"N)Úreplace)Ú.0Úquerys   & r%   Ú	<genexpr>Ú6CharmedMySQL._collect_per_namespace.<locals>.<genexpr>ª   s%   é € ð á/�Eð —‘˜d F×+Ð+Û/ùs   ‚!Ú	mysql_pwdÚwÚutf8)Úencodingz	 exec -c z -- mkdir -p z -- sh -lc 'MYSQL_PWD=$(cat z) z "z"' && rm -rf z_dbs.txt)Úsuggest_filename)r-   Úadd_cmd_outputr.   r:   Úget_cmd_output_pathÚ
conf_pathsÚitemsr   Úmakedirsr,   Úadd_forbidden_pathr   r&   ÚjoinÚmysql_queriesÚtempfileÚTemporaryDirectoryÚopenÚwrite)r"   r8   r   r-   Ú
mysql_contr9   Údump_files_pathÚnameÚpathÚpodÚcopy_cmdr#   r$   ÚoptsÚsql_cmdÚqueriesÚtmpdirÚpwd_fileÚpwd_pathÚfÚ	mkdir_cmdÚqueries_cmds   &&&                   r%   Ú_collect_per_namespaceÚ#CharmedMySQL._collect_per_namespace€   s  € Ø—m‘m�_ D¨¨Ð4ˆð 	×ÑØˆj˜ T§]¡] O°8Ð<ØˆjÐ*¨4¯=©=¨/Ð:ð
ô 	ð 	×ÑØˆj˜	 $§-¡- °	¸*¸ð F8ð 8ô	
ð
 ˆ
Ø×"Ñ" 9Ó-ˆð ×2Ñ2Ó4ˆØŸ/™/×/Ñ/Ö1‰JˆDÛ�Ü—’˜Ð/¨q°°°Q°t°fÐ=ÈÕMà�j ¨
 |°1°S°E¸¸4¸&ÀØ&Ð' q¨¨¨Q¨t¨fð6ð ð —‘˜hÖ'ó ñ 2ð 	×ÑØÐÐ2Ð3ØÐÐ2Ð3ð!
ô 	ð �?‰?˜9×%Ó%Ø#×7Ñ7Ó9ÑˆGß§'Ùà$ W IÐ.ˆDØ˜t˜f CÐ(ˆGØ—h‘hñ à!×/Ò/óó ˆGô
 ×,Ò,×.Ô.°&Ø&�Ø! C�<¨(Õ2�ä˜( C°&×9Õ9¸QØ—G‘G˜GÔ$÷ :ó  �Cà#˜* I¨j¨\¸¸3¸%ð @$Ø$* 8ð-ð ð —M‘M )Ô,ð $˜* G¨J¨<°qØ#˜* A c U¨!¨H¨:ð7ð ð —M‘M (Ô+ð $˜* I¨j¨\¸¸3¸%ð @3Ø3;°*¸BØ"˜) 3 w ið 0%Ø%+ Hð.ð  ð ×'Ñ'Ø#Ø,/¨5°Ð)9ð (ö ñ'  ÷ /Ñ.ñ &÷  :×9ú÷	 /×.Ð.ús%   Æ)I3ÇI 	ÇA<I3É I0É+I3É3J	c                ó¾   € V Uu. uF+  q3P                  \        P                  P                  4      NK-  	  pp\        P                  P                  ! V.VO5!  # u upi ©N)Úlstripr   r_   ÚseprV   )r"   ÚbaseÚpartsÚpÚstripped_partss   &&*  r%   Ú_join_conf_pathÚCharmedMySQL._join_conf_pathÎ   sC   € Ù9>Ó?¹°AŸ(™(¤2§7¡7§;¡;Ö/¹ˆÐ?Ü�w‰w�|Š|˜DÐ2 >Ó2Ð2ùò @s   …1Ac                ó|   € V P                  R 4      pV P                  4       pV F  pV P                  W14       K  	  R# )r   N)r   r4   rk   )r"   r   r3   r8   s   &   r%   Ú_process_k8sÚCharmedMySQL._process_k8sÒ   s6   € Ø—_‘_ \Ó2ˆ
Ø×/Ñ/Ó1ˆ
Û#ˆIØ×'Ñ'¨	Ö>ó $r(   c                ó   € V P                  V P                  V P                  V P                  R ,          R4      V P                  V P                  V P                  R ,          R4      .4       V P	                  V P                  V P                  V P                  R ,          4      V P                  V P
                  V P                  R,          4      V P                  V P                  V P                  R,          4      V P                  V P
                  V P                  R,          4      V P                  V P
                  V P                  R,          4      .4       V P                  R4       V P                  R4       V P                  R	4      '       dh   V P                  4       w  rV'       d	   V'       g   R
# RV/pRV 2pRV R2pT P                  V P                   Uu. uF
  qe RV R2NK  	  upVR7       R
# R
# u upi )r   z*.pemz*.keyr   r   r   r   zsnap.charmed-mysql.*zsnap info charmed-mysqlr   Nr   rA   rB   rC   z 'Ú')Úenv)rU   ru   Úsnap_path_currentrR   Úadd_copy_specÚsnap_path_commonÚadd_journalrP   r   r&   rW   )r"   r#   r$   Ú	mysql_envrb   rc   rH   s   &      r%   Ú_process_snapÚCharmedMySQL._process_snapØ   sè  € à×ÑØ× Ñ Ø×&Ñ&Ø—‘ Õ-Øóð
 × Ñ Ø×&Ñ&Ø—‘ Õ-Øóð!
ô 	ð 	×ÑØ× Ñ Ø×&Ñ&Ø—‘ Õ-óð × Ñ Ø×%Ñ%Ø—‘ Õ-óð × Ñ Ø×&Ñ&Ø—‘Ð 3Õ4óð × Ñ Ø×%Ñ%Ø—‘Ð 3Õ4óð × Ñ Ø×%Ñ%Ø—‘Ð 2Õ3óð#
ô 	ð0 	×ÑÐ/Ô0ð 	×ÑÐ5Ô6ð �?‰?˜9×%Ò%Ø#×7Ñ7Ó9ÑˆGß§'Ùà$ gÐ.ˆIØ$ W IÐ.ˆDØ˜t˜f CÐ(ˆGà×ÑØ59×5GÒ5GÓHÑ5G¨E�9˜B˜u˜g QÓ'Ñ5GÑHØð  ö ñ &ùò Is   ÇG;c                óÊ   € V P                  V P                  4      '       d   R # \        V P                  V P                  4      ;'       d    \        V P                  4       4      # )T)Úis_installedÚsnap_packager   r-   ÚsysrootÚboolr4   ©r"   s   &r%   Úcheck_enabledÚCharmedMySQL.check_enabled  sP   € à×Ñ˜T×.Ñ.×/Ò/Ùô ˜$Ÿ-™-¨¯©Ó6÷ /ð /Ü�×+Ñ+Ó-Ó.ð	
r(   c                óØ   € V P                  V P                  4      '       d   V P                  4        \        V P                  V P
                  4      '       d   V P                  4        R # R # rn   )r…   r†   r‚   r   r-   r‡   rx   r‰   s   &r%   ÚsetupÚCharmedMySQL.setup  sK   € Ø×Ñ˜T×.Ñ.×/Ò/Ø×ÑÔ ä˜Ÿ™¨¯©×5Ò5Ø×ÑÖñ 6r(   © N)zshow databases;z*select * from mysql.juju_units_operations;zPselect * from performance_schema.replication_group_members order by MEMBER_HOST;z"show global status like "%conne%";z,select * from performance_schema.host_cache;zshow ENGINE InnoDB STATUS;)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú
short_descÚplugin_namerW   r†   r   r}   r-   r.   rR   r   Ústrrˆ   Úoption_listr&   r4   r:   rk   ru   rx   r‚   rŠ   r�   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r%   r   r      sì   ø‡ € ñð !€JØ!€Kò€Mð. #€LØ7ÐØ9Ðà€HØ1€Hð 	�lØÐ&ØÐ/ØÐ3ØÐ.ð€Jñ 	Ø˜g°Ø8ô	
ñ 	Ø˜b¨3Ø8ô	
ñ 	Ø˜u¨tØ,ô	
ñ 	Ø %°#ØLô	
ð€Kò& ò&òòLò\3ò?ò:òx	
÷ ð  r(   r   )	r   rX   Úsos.report.pluginsr   r   r   Úsos.utilitiesr   r   r�   r(   r%   Ú<module>rž      s&   ðó 
Û ç >Ñ >Ý 'ôT �6˜<ö T r(   