HEX
Server: LiteSpeed
System: Linux baran.dnsprotection.me 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: ddir12 (3618)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/glances/plugins/__pycache__/glances_raid.cpython-36.opt-1.pyc
3

Eo�c��@s�dZddlmZddlmZddlmZyddlmZWn6e	k
rnZ
zdZejdj
e
��WYddZ
[
XnXd	ZGd
d�de�ZdS)zRAID plugin.�)�iterkeys)�logger)�
GlancesPlugin)�MdStatTz0Missing Python Lib ({}), Raid plugin is disabledNFcsHeZdZdZd�fdd�	Zejejdd���Zddd�Z	d	d
�Z
�ZS)
�PluginzKGlances RAID plugin.

    stats is a dict (see pymdstat documentation)
    Ncstt|�j||d�d|_dS)zInit the plugin.)�args�configTN)�superr�__init__Z
display_curse)�selfrr)�	__class__��"/usr/lib/python3.6/glances_raid.pyr
 szPlugin.__init__cCs||j�}tr|jS|jdkrfyt�}|j�d}Wqptk
rb}ztjd|�|jSd}~XqpXn
|jdkrp||_|jS)z)Update RAID stats using the input method.Zlocal�arrayszCan not grab RAID stats (%s)NZsnmp)	Zget_init_value�import_error_tag�statsZinput_methodrZ	get_stats�	Exceptionr�debug)rrZmds�er
r
r�update's

z
Plugin.updatecCs�g}|js|j�r|S|d}djd|d�}|j|j|d��djd�}|j|j|��djd�}|j|j|��tt|j��}�x|D�]�}|j|j��|j|j|d	|j|d
|j|d|j|d�}|j|dd
k	r�|j|dj	�nd}	dj|	|�}
dj|
|d�}|j|j|��|j|ddk�r�|j|d	dk�r�djt
|j|d��}|j|j||��djd�}|j|j||���nF|j|d	dk�r�dj|j|d
�}|j|j||��dj|j|d�}|j|j||��n�|j|d	dk�r�|j|j��dj|j|d	�}|j|j||��tt|j|d��}x�t|�D]x\}}
|t
|�dk�r�d}nd}|j|j��dj||j|d|
�}|j|j|��dj|
�}|j|j|���qdW|j|ddkr�|j|d
|j|dkr�|j|j��d}|j|j||��t
|j|d�dkr�|j|j��dj|j|djdd ��}|j|j|��q�W|S)!z2Return the dict to display in the curse interface.�z
{:{width}}z
RAID disks)�widthZTITLEz{:>7}ZUsedZAvail�status�used�	available�typeNZUNKNOWNz{} {}�raid0Zactive�
components�-�inactiveu└─ Status {}�u└─u├─z   {} disk {}: z{}u└─ Degraded moder�u   └─ {}�_�A)
rZis_disabled�format�appendZcurse_add_line�sortedrZcurse_new_line�
raid_alert�upper�len�	enumerate�replace)rrZ	max_width�retZname_max_width�msgrZarrayrZ
array_typeZ	full_namer�iZ	componentZ	tree_charr
r
r�	msg_curseFsn

((

.zPlugin.msg_cursecCs<|dkrdS|dkrdS|dks(|dkr,dS||kr8dSdS)z�RAID alert messages.

        [available/used] means that ideally the array may have _available_
        devices however, _used_ devices are in use.
        Obviously when used >= available then things are good.
        rZOKrZCRITICALNZDEFAULTZWARNINGr
)rrrrrr
r
rr'�szPlugin.raid_alert)NN)NN)�__name__�
__module__�__qualname__�__doc__r
rZ_check_decoratorZ_log_result_decoratorrr/r'�
__classcell__r
r
)rrrs
Jr)r3Zglances.compatrZglances.loggerrZglances.plugins.glances_pluginrZpymdstatr�ImportErrorrrZwarningr$rr
r
r
r�<module>
s"