????

Your IP : 3.135.209.235


Current Path : /lib/python3.6/site-packages/glances/plugins/sensors/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/glances/plugins/sensors/__pycache__/glances_hddtemp.cpython-36.pyc

3

Eo�c.�@s`dZddlZddlZddlmZmZddlmZddlm	Z	Gdd�de	�Z
Gdd	�d	e�ZdS)
zHDD temperature plugin.�N)�	nativestr�range)�logger)�
GlancesPlugincs0eZdZdZd�fdd�	Zejdd��Z�ZS)�PluginzAGlances HDD temperature sensors plugin.

    stats is a list
    NcsVtt|�j||gd�|jddgd�d}t|jddd��}t|||d�|_d	|_d
S)zInit the plugin.)�args�configZstats_init_value�hostz	127.0.0.1)�defaultr�portZ7634)rr	rFN)�superr�__init__Zget_conf_value�int�GlancesGrabHDDTemp�hddtempZ
display_curse)�selfrrZhddtemp_hostZhddtemp_port)�	__class__��%/usr/lib/python3.6/glances_hddtemp.pyr
s
zPlugin.__init__cCs*|j�}|jdkr|jj�}n||_|jS)z(Update HDD stats using the input method.Zlocal)Zget_init_valueZinput_methodr�get�stats)rrrrr�update(s

z
Plugin.update)NN)	�__name__�
__module__�__qualname__�__doc__r
rZ_log_result_decoratorr�
__classcell__rr)rrrsrc@s:eZdZdZddd�Zdd�Zd	d
�Zdd�Zd
d�ZdS)rz,Get hddtemp stats using a socket connection.�	127.0.0.1��NcCs$||_||_||_d|_|j�dS)zInit hddtemp stats.�N)rr	r�cache�reset)rr	rrrrrr
@s
zGlancesGrabHDDTemp.__init__cCs
g|_dS)zReset/init the stats.N)�hddtemp_list)rrrrr!HszGlancesGrabHDDTemp.resetc
Cs(|j�|j�}|dkrdSt|�dkrDt|j�dkr<|jn|j�}||_y|jd�}Wntk
rpd}YnXt|�dd}x�t|�D]�}|d}i}tjj	t
||d��}||d}t
||d	�}	||d
<yt|�|d<Wn"tk
�r
t
|�|d<YnX|	|d<|j
j|�q�WdS)
zUpdate the stats.rN�r�|����Zlabel�value�unit)r!�fetch�lenr �split�	TypeErrorr�os�path�basenamer�float�
ValueErrorr"�append)
r�dataZfieldsZdevices�item�offsetZhddtemp_currentZdeviceZtemperaturer*rrr�
__update__Ls2
zGlancesGrabHDDTemp.__update__cCs�z�yHtjtjtj�}|j|j|jf�d}x|jd�}|s<P||7}q,WWnZtk
r�}z>tj	dj
|j|j|��tj	d�|jdk	r�d|j_d}WYdd}~XnXWd|j
�|dkr�tj	dj
|��X|S)	z#Fetch the data from hddtemp daemon.�iz1Cannot connect to an HDDtemp server ({}:{} => {})zSDisable the HDDtemp module. Use the --disable-hddtemp to hide the previous message.NTrz)Received data from the HDDtemp server: {})�socketZAF_INETZSOCK_STREAMZconnectr	rZrecv�	Exceptionr�debug�formatrZdisable_hddtemp�close)rZsckr5Zreceived�errrr+{s&


zGlancesGrabHDDTemp.fetchcCs|j�|jS)zGet HDDs list.)r8r")rrrrr�szGlancesGrabHDDTemp.get)rrN)	rrrrr
r!r8r+rrrrrr=s
/r)
rr/r:Zglances.compatrrZglances.loggerrZglances.plugins.glances_pluginrr�objectrrrrr�<module>
s)