MOON
Server: Apache
System: Linux vps.erhabenn.com.br 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User: sonne (1011)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //usr/lib/mysqlsh/plugins/debug/__pycache__/host_info.cpython-39.pyc
a

��kfh!�@sPddlmZmZmZddlZddlZddlZddlZddlm	Z	m
Z
ddlZddlZddl
Z
ddlZgd�Zgd�Zgd�Zeeeeeeeeefd�dd	�ZGd
d�d�Zdd
�Zd!eeeed�dd�Zejed�dd�Zed�dd�Zdd�Zedk�rLe�dd��(Zeedddidd ig�Wd�n1�sB0YdS)"�)�List�Optional�TupleN)�globals�Error)�date�uname -a�mount -v�df -hz	iostat -Kztop -l4 -s1�ps aux�	ulimit -a�dmesg�%egrep -i 'err|fault|mysql' /var/log/*znetstat -ln�	sysctl -a)zdate /T�verZ
systeminfoztasklist /V)!rrZ
getenforcezfree -mz	swapon -szlsb_release -ar	r
zcat /proc/cpuinfozcat /proc/meminfozcat /etc/fstabzmpstat -P ALL 1 4ziostat -m -x 1 4z
vmstat 1 4ztop -b -n 4 -d 1rrz�for PID in `pidof mysqld`;do echo "# numastat -p $PID";numastat -p $PID;echo "# /proc/$PID/limits";cat /proc/$PID/limits;echo;doner
rZpvsZ	pvdisplayZvgsZ	vgdisplayZlvsZ	lvdisplayznetstat -lnputznumactl --hardwareznumastat -mrz dmidecode -s system-product-namezlsblk -izsudo sosreport)�l�returncCs�g}g}g}|D]z}|���d�r8|�|�d�d�q|���d�r\|�|�d�d�q|���d�r�|�|�d�d�q|�|�q|||fS)Nzbefore:�:���zduring:zafter:)�lower�
startswith�append�	partition)r�beforeZduringZafter�s�r�+/usr/lib/mysqlsh/plugins/debug/host_info.py�split_phasesVsrc@speZdZgdfeeed�dd�Zejed�dd�Z	ejed�dd	�Z
ejeed
�dd�Zejed�d
d�Z
dS)�
ShellExecutorT)�custom_shell�allow_phasescCs.t|�|_|s*|jds"|jdr*td��dS)N��zHOption 'customShell' may not contain before:, during: or after: prefixes)rrr)�selfrr rrr�__init__gs
�zShellExecutor.__init__��zf�prefixcCs0|jd}|r,td�t||�d�|dd�dS)NrzExecuting custom shell scriptszcustom_shell.txtF��
ignore_errors�r�print�run_shell_scripts�r#r&r'rrrr�executeos
�zShellExecutor.executecCs0|jd}|r,td�t||�d�|dd�dS)Nrz'Executing custom 'before' shell scriptszcustom_shell-before.txtFr(r*r-rrr�execute_beforevs
�zShellExecutor.execute_before)r&r'�	iterationcCs6|jd}|r2td�t||�d|�d�|dd�dS)Nr!z1Executing custom 'during' iteration shell scriptszcustom_shell-iterationz.txtFr(r*)r#r&r'r0rrrr�execute_during}s
�zShellExecutor.execute_duringcCs0|jd}|r,td�t||�d�|dd�dS)Nr"z&Executing custom 'after' shell scriptszcustom_shell-after.txtFr(r*r-rrr�
execute_after�s
�zShellExecutor.execute_afterN)�__name__�
__module__�__qualname__r�str�boolr$�zipfile�ZipFiler.r/�intr1r2rrrrrfs
rcCs�tj|dtjtjd�}|�d|�d��d��|�dtj�����d��d��|�d|j	�d��d��|�|j
�|�d�|j	S)NT)�shell�stdout�stderrz# �
�utf-8z
# exitcode = s


)�
subprocess�run�PIPE�STDOUT�write�encode�datetime�now�	isoformat�
returncoder<)�f�cmd�rrrr�dump_shell_cmd�s�"
rMT)�fn�scriptsr)cCsr|�|d��R}|D]<}td|���t||�}|dkr|std|�d|����qWd�n1sd0YdS)N�wz -> Executing rzShell command "z" exited with code )�openr+rMr)r&rNrOr)rJrK�rcrrrr,�s
r,r%cCs�tj�t��d�}dd|g}|�|�d��>}tdd�|��t||�|�t|d��	��Wd�n1sn0Yt�
|�dS)Nzmysqlsh_msinfo32.txtZmsinfo32z/reportrPZ	Executing� �rb)�os�path�join�tempfile�
gettempdirrQr+rMrD�read�remove)r&r'Z	temp_path�argsrJrrr�collect_msinfo32�s

2r])r'cCsng}tjdkrt}n(tjdvr.t}t||�ntjdkr<t}tdt���dtj�d��t	||�d�|�dS)N�darwin)�win32�cygwinZmsys�linuxz"Collecting system information for z (�)Z	host_info)
�sys�platform�k_host_info_cmds_macos�k_host_info_cmds_win32r]�k_host_info_cmds_linuxr+�socket�gethostnamer,)r&r'Zcmdlistrrr�collect_host_info�s


�rjc	Csdd�}tj}g}g}tdt���d��|D]X}|d}|d}	|�|�d}
td|
�d	��|�tj||
|	|fd
��|d�	�q.|D]}|�
�q�|�|�d�d
��\}|D]F\}	}
}
|�d|	�d|
�d��
d��|�d�|�|
�|�d�q�Wd�n1�s0YdS)Nc
Ss~z:tjdtjdkrdndd|gdd�}|�|||jf�Wn>tyx}z&|�||t|��d�f�WYd}~n
d}~00dS)	N�pingr_z/nz-c�5T)�capture_outputr?)	r@rArcrdrr<�FileNotFoundErrorr6rE)�host�instance_id�timingsrL�errrrk�s��z collect_ping_stats.<locals>.pingzExecuting ping from z to other member hosts...�endpointrproz - Executing ping z
 for 5s...)�targetr\rzping.txtrPz# instance z - ping r>r?�
)rr;r+rhri�	parse_urir�	threading�Thread�startrWrQrDrE)r&r'�
topology_datarkr;�threadsrq�instancersrproZthdrJ�outrrr�collect_ping_stats�s4	�
�
�

r~�__main__ztest.ziprP�testrs�	localhostzwww.oracle.com)T)�typingrrrr8rhrwr@�mysqlshrrrcrFrXrUrerfrgr6rrrMr7r,r9r]rjr~r3r&rrrr�<module>s0
 *'

&
�