403Webshell
Server IP : 77.50.203.18  /  Your IP : 192.168.0.10
Web Server : Apache/2.4.62 (CentOS Stream) OpenSSL/3.5.7 mpm-itk/2.4.7-04 PHP/8.4.23
System : Linux web2 5.14.0-722.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Mon Jul 6 09:07:51 UTC 2026 x86_64
User : warsnews.ru ( 1001)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.9/site-packages/sos/report/plugins/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.9/site-packages/sos/report/plugins/__pycache__/charmed_mysql.cpython-39.opt-1.pyc
a

ܓ�i�&�@sFddlZddlZddlmZmZmZddlmZGdd�dee�ZdS)�N)�Plugin�	PluginOpt�UbuntuPlugin)�
is_executablec	@s�eZdZdZdZdZgd�ZdZdZdZ	dZ
d	Zd
ddd
dd�Ze
ddedd�e
ddedd�e
ddedd�e
ddedd�gZdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/S)0�CharmedMySQLa�
    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 MySQLZ
charmed_mysql)zshow 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;zshow ENGINE InnoDB STATUS;z
charmed-mysqlz/var/snap/charmed-mysql/commonz/var/snap/charmed-mysql/currentZkubectlz app.kubernetes.io/name=mysql-k8sz
/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_LOGS�dbuser�mysqlz%Username for database dump collection)�defaultZval_typeZdesc�dbpass�z%Password for database dump collection�dumpdbsFzGet name of all databases�
logs_sinceZ48hz9How far back to fetch logs with kubectl --since, K8s onlycCsV|�d�}|�d�}dtjvr:|s:|j�d�tjd}n|sN|j�d�dS||fS)Nr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�environZsoslog�infoZwarning)�self�db_user�db_pass�r�D/usr/lib/python3.9/site-packages/sos/report/plugins/charmed_mysql.py�_get_db_credentials[s

��z CharmedMySQL._get_db_credentialscCsB|�|j�d|j�d��}|ddkr>tt|d������SgS)Nz get pods -A -l z- -o jsonpath='{.items[*].metadata.namespace}'�statusr�output)�exec_cmd�kube_cmd�selector�list�set�strip�split)r�
namespacesrrr�_determine_namespacesns�z"CharmedMySQL._determine_namespacescCs@|�|j�d|�d|j�d��}|ddkr<|d����SgS)N� -n z
 get pods -l z( -o jsonpath='{.items[*].metadata.name}'rrr)r r!r"r%r&)r�	namespace�podsrrr�_get_pod_namesws�zCharmedMySQL._get_pod_namescCs^|j�d|��}|�|�d|j�d�|�d|j��g�|�|�d|j�d|�d��d}|�|�}|��}|j��D]f\}}|D]X}	tj|�d	|	�d	|��d
d�|�d|�d
|	�d|�d
|�d	|	�d	|��
}
|�	|
�q�qv|�
|�d�|�d�g�|�d��rZ|��\}}|�r|�s dSd|��}
d|
�d�}d
�
dd�|jD��}t����}d}|d	|}t|ddd��}|�|�Wd�n1�s�0Y|D]�}	|�d|�d
|	�d|��}|�	|�|�d|�d
|�d
|	�d|��	}
|�	|
�|�d|�d
|	�d|�d|�d|�d |��
}|j||	�d!�d"��q�Wd�n1�sP0YdS)#Nr)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�-h 127.0.0.1 -u�mysql � -ecss|]}|�dd�VqdS)�"z\"N)�replace��.0�queryrrr�	<genexpr>�s�z6CharmedMySQL._collect_per_namespace.<locals>.<genexpr>Z	mysql_pwd�w�utf8)�encodingz	 exec -c z
 -- mkdir -p z -- sh -lc 'MYSQL_PWD=$(cat z) z "z
"' && rm -rf z_dbs.txt)Zsuggest_filename)r!�add_cmd_outputr"r,Zget_cmd_output_path�
conf_paths�itemsr�makedirsr �add_forbidden_pathrr�join�
mysql_queries�tempfileZTemporaryDirectory�open�write)rr*rr!Z
mysql_contr+Zdump_files_path�name�pathZpodZcopy_cmdrr�opts�sql_cmdZqueriesZtmpdirZpwd_fileZpwd_path�fZ	mkdir_cmdZqueries_cmdrrr�_collect_per_namespace�s���
�����

�
*��
����
������z#CharmedMySQL._collect_per_namespacecGs"dd�|D�}tjj|g|�R�S)NcSsg|]}|�tjj��qSr)�lstriprrH�sep)r7�prrr�
<listcomp>��z0CharmedMySQL._join_conf_path.<locals>.<listcomp>)rrHrB)r�base�partsZstripped_partsrrr�_join_conf_path�szCharmedMySQL._join_conf_pathcCs,|�d�}|��}|D]}|�||�qdS)Nr)rr(rL)rrr'r*rrr�_process_k8s�s
zCharmedMySQL._process_k8scs|�|�|j|jdd�|�|j|jdd�g�|�|�|j|jd�|�|j|jd�|�|j|jd�|�|j|jd�|�|j|jd�g�|�d�|�d	�|�d
��r
|�	�\}}|r�|s�dSd|i}d|��}d
|�d��|j�fdd�|j
D�|d�dS)Nrz*.pemz*.keyrr	r
rzsnap.charmed-mysql.*zsnap info charmed-mysqlrrr1r2r3csg|]}��d|�d��qS)z '�'rr6�rJrrrPrQz.CharmedMySQL._process_snap.<locals>.<listcomp>)�env)rArT�snap_path_currentr>Z
add_copy_spec�snap_path_commonZadd_journalr=rrrC)rrrZ	mysql_envrIrrWr�
_process_snap�s^���������


�zCharmedMySQL._process_snapcCs*|�|j�rdSt|j|j�o(t|���S)NT)�is_installed�snap_packagerr!�sysroot�boolr(�rrrr�
check_enableds

�zCharmedMySQL.check_enabledcCs.|�|j�r|��t|j|j�r*|��dS)N)r\r]r[rr!r^rUr`rrr�setupszCharmedMySQL.setupN)�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_namerCr]rZrYr!r"r>r�strr_Zoption_listrr(r,rLrTrUr[rarbrrrrrsR�	�����		N<r)	rrDZsos.report.pluginsrrrZ
sos.utilitiesrrrrrr�<module>	s

Youez - 2016 - github.com/yon3zu
LinuXploit