????

Your IP : 3.19.208.67


Current Path : /proc/self/root/lib/python3.6/site-packages/glances/plugins/__pycache__/
Upload File :
Current File : //proc/self/root/lib/python3.6/site-packages/glances/plugins/__pycache__/glances_irq.cpython-36.pyc

3

Eo�c��@s\dZddlZddlZddlmZddlmZddlmZGdd�de�Z	Gdd	�d	e
�ZdS)
zIRQ plugin.�N)�LINUX)�getTimeSinceLastUpdate)�
GlancesPlugincsTeZdZdZd
�fdd�	Zdd�Zejejdd���Z	�fd	d
�Z
ddd�Z�ZS)�Pluginz-Glances IRQ plugin.

    stats is a list
    Ncs(tt|�j||gd�d|_t�|_dS)zInit the plugin.)�args�configZstats_init_valueTN)�superr�__init__Z
display_curse�
GlancesIRQ�irq)�selfrr)�	__class__��!/usr/lib/python3.6/glances_irq.pyr	szPlugin.__init__cCs
|jj�S)zReturn the key of the list.)r�get_key)rrrrr$szPlugin.get_keycCsZ|j�}ts|jS|jdkr(|jj�}n
|jdkr2t|tjd�dd�dd�}||_|jS)zUpdate the IRQ stats.ZlocalZsnmp�irq_rateT)�key�reverseN�)	Zget_init_valuer�statsZinput_methodr�get�sorted�operator�
itemgetter)rrrrr�update(s

z
Plugin.updatecstt|�j�dS)zUpdate stats views.N)rr�update_views)r)r
rrrCszPlugin.update_viewscCs�g}ts|js|j�r|S|d}djd|d�}|j|j|d��djd�}|j|j|��xh|jD]^}|j|j��dj|dd	|�|d�}|j|j|��djt|d
��}|j|j|��qhW|S)z2Return the dict to display in the curse interface.�z
{:{width}}ZIRQ)�widthZTITLEz{:>9}zRate/s�irq_lineNr)rrZis_disabled�format�appendZcurse_add_lineZcurse_new_line�str)rrZ	max_width�retZname_max_width�msg�irrr�	msg_curseHs
zPlugin.msg_curse)NN)NN)
�__name__�
__module__�__qualname__�__doc__r	rrZ_check_decoratorZ_log_result_decoratorrrr%�
__classcell__rr)r
rrs
rc@sTeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dd�Zdd�ZdS)r
z This class manages the IRQ file.z/proc/interruptscCsi|_|j�dS)zPInit the class.

        The stat are stored in a internal list of dict
        N)�lasts�reset)rrrrr	kszGlancesIRQ.__init__cCsg|_d|_dS)zReset the stats.rN)r�
cpu_number)rrrrr,sszGlancesIRQ.resetcCs|j�S)zReturn the current IRQ stats.)�_GlancesIRQ__update)rrrrrxszGlancesIRQ.getcCsdS)zReturn the key of the dict.rr)rrrrr|szGlancesIRQ.get_keycCst|j��|_|jS)z�Build the header (contain the number of CPU).

        CPU0       CPU1       CPU2       CPU3
        0:         21          0          0          0   IO-APIC   2-edge      timer
        )�len�splitr-)r�linerrrZ__header�szGlancesIRQ.__headercCs6|j�}|djdd�}|j�r2|dj|d�7}|S)aReturn the IRQ name, alias or number (choose the best for human).

        IRQ line samples:
        1:      44487        341         44         72   IO-APIC   1-edge      i8042
        LOC:   33549868   22394684   32474570   21855077   Local timer interrupts
        r�:�z_{}����)r0�replace�isdigitr)rr1�
splitted_linerrrrZ__humanname�s
zGlancesIRQ.__humannamec
CsF|j�}y ttt|d|jd���}Wntk
r@d}YnX|S)z�Return the IRQ sum number.

        IRQ line samples:
        1:     44487        341         44         72   IO-APIC   1-edge      i8042
        LOC:   33549868   22394684   32474570   21855077   Local timer interrupts
        FIQ:   usb_fiq
        r4r)r0�sum�map�intr-�
ValueError)rr1r8r"rrrZ__sum�s 
zGlancesIRQ.__sumcCs�|j�tjj|j�s|jSy�t|j���}td�}|j|j	��xt|j
�D]h}|j|�}|j|�}t
|jj|�r�||jj|�nd|�}|||j�|d�}|jj|�||j|<qJWWdQRXWnttfk
r�YnX|jS)z/Load the IRQ file and update the internal dict.rr)rrr�time_since_updateN)r,�os�path�exists�IRQ_FILEr�openr�_GlancesIRQ__header�readline�	readlines�_GlancesIRQ__humanname�_GlancesIRQ__sumr;r+rrr �OSError�IOError)rZirq_procr=r1rZcurrent_irqsrZirq_currentrrrZ__update�s*

&zGlancesIRQ.__updateN)
r&r'r(r)rAr	r,rrrCrFrGr.rrrrr
fs	r
)r)r>rZglances.globalsrZ
glances.timerrZglances.plugins.glances_pluginrr�objectr
rrrr�<module>
sR