|
Server : LiteSpeed System : Linux host 5.15.0-161-generic #171-Ubuntu SMP Sat Oct 11 08:17:01 UTC 2025 x86_64 User : idnco5810 ( 1093) PHP Version : 8.2.29 Disable Function : NONE Directory : /lib/python3/dist-packages/sos/report/plugins/__pycache__/ |
Upload File : |
o
([Qh� � @ s6 d dl Z d dlZd dlmZmZ G dd� dee�ZdS )� N)�Plugin�UbuntuPluginc @ s4 e Zd ZdZdZdZdZdZdZdd� Z dd � Z
d
S )�Microk8sa The Microk8s plugin collects the current status of the microk8s
snap on a Ubuntu machine.
It will collect logs from journald related to the snap.microk8s
units as well as run microk8s commands to retrieve the configuration,
status, version and loaded plugins.
zThe lightweight Kubernetes�microk8s)� container)r c
s � j dd� g d�}� �d� � �� fdd�|D �� d}|� d�}� �d |� d
�� d}� j|dd� � �|� d
�|� d�|� d�g� d}|� d�}|� d�}|� d�}|� d|� d|� d|� d�} ddd�ddgdd�ddd�g}
z8t|ddd��'}|�� }t�d|�}
|
D ]}|
�d |� �d!|� �dgd"�� q�W d � n1 s�w Y W n t y� } z� �
d#|� d$|� �� W Y d }~nd }~ww |
D ]2}| }|�d%g �}|D ] }|� d&|� �}q�t�
|�d'��}|�d(�}� j|� d&|� �d)|� �d� q�d S )*Nzsnap.microk8s.*)�units)zaddons repo list�configzctr plugins lszctr plugins ls -d�status�version�4/var/snap/microk8s/current/credentials/client.configc s g | ]
}� j � d |� ��qS )� )�microk8s_cmd)�.0�subcmd��self� �=/usr/lib/python3/dist-packages/sos/report/plugins/microk8s.py�
<listcomp>1 s �z"Microk8s.setup.<locals>.<listcomp>z1/var/snap/microk8s/current/var/kubernetes/backendz/cluster.crtzopenssl x509 -in z -noout -dates�ls_microk8s_dqlite_dir)�suggest_filenamez
/info.yamlz
/cluster.yamlz/failure-domainz!/snap/microk8s/current/bin/dqlitez/cluster.keyz -c z -k z -s file://z k8sz.cluster)�query�suggested_file_suffixz-f jsonz.cluster_-f_json)r �optsr z.leader�rzutf-8)�encodingz#Address:\s*(\d+\.\d+\.\d+\.\d+:\d+)z
.describe z
.describe_)r r r zFailed to parse z: r r r r �
microk8s_sql_)�add_journal�
add_copy_spec�add_cmd_output�add_dir_listing�open�read�re�findall�append� Exception� add_alert�get�json�dumps)r �microk8s_subcmds�crt_dir�
dqlite_crt�db_path�
dqlite_bin�cert�key�servers�
dqlite_cmd�queries�cluster_definition�cluster�nodes�node�e�query_entry�sql_cmdr �optr �file_suffixr r r �setup"