Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.6/site-packages/agent360/plugins/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.6/site-packages/agent360/plugins/__pycache__/diskstatus.cpython-36.pyc

3

�uGh��@sPddlZddlZddlZddlZddlZGdd�dej�ZedkrLe�j�dS)�Nc@seZdZdZdd�ZdS)�PluginZ
diskstatuscCs�i}y.tjdtjtjdd�j�dj�j�}d}Wn$tk
rV}zd}dSd}~XnX|dk�r��x(|D�]}y�|jd�djd	�d
}tj	dj
|jd�d��j�j�}d}	|djd
�ddkr�d}	i||<d}
xv|D]n}|dd�dkr�d}
q�|
dk�rq�tj
dd|�j�}|jd�}t|�dkr�|d|||dj�jdd�<q�W|	||d<Wqjtk
�r�}zt|�WYdd}~XqjXqjW|S)a
        Monitor nvme or smart disk status.
        For NVME drives use the diskstatus-nvme plugin
        for smart status install smartmontools (apt-get/yum install smartmontools)
        This plugin requires the agent to be run under the root user.
        zsmartctl --scanT)�stdout�stderr�shellrFz+Could not fetch smartctl status informationN� �/�zsmartctl -A -H {}�z: �ZPASSED�zID#z +�	Z_celsius��status)�
subprocess�Popen�PIPE�communicate�decode�
splitlines�	Exception�split�os�popen�format�read�re�sub�strip�len�lower�replace�print)�self�config�resultsZdevlistZsmartctl�e�rowZdisk_idZ
disk_statsZsmart_status�start�stats�r)�D/root/tmp/pip-build-gzoz1_uw/agent360/agent360/plugins/diskstatus.py�runs>&
"


$z
Plugin.runN)�__name__�
__module__�__qualname__r+r)r)r)r*r	sr�__main__)	rrZplugins�jsonrZ
BasePluginrr,�executer)r)r)r*�<module>s-

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists