????
Current Path : /proc/self/root/lib/python3.6/site-packages/glances/plugins/__pycache__/ |
Current File : //proc/self/root/lib/python3.6/site-packages/glances/plugins/__pycache__/glances_irq.cpython-36.pyc |
3 Eo�c� � @ s\ d Z ddlZddlZddlmZ ddlmZ ddlmZ G dd� de�Z G dd � d e �ZdS ) zIRQ plugin.� N)�LINUX)�getTimeSinceLastUpdate)� GlancesPluginc sT e Zd ZdZd � fdd� Zdd� Zejejdd� ��Z � fd d �Z ddd�Z� ZS )�Pluginz-Glances IRQ plugin. stats is a list Nc s( t t| �j||g d� d| _t� | _dS )zInit the plugin.)�args�configZstats_init_valueTN)�superr �__init__Z display_curse� GlancesIRQ�irq)�selfr r )� __class__� �!/usr/lib/python3.6/glances_irq.pyr s zPlugin.__init__c C s | j j� S )zReturn the key of the list.)r �get_key)r r r r r $ s zPlugin.get_keyc C sZ | j � }ts| jS | jdkr(| jj� }n | jdkr2t|tjd�dd�dd� }|| _| jS )zUpdate the IRQ stats.ZlocalZsnmp�irq_rateT)�key�reverseN� ) Zget_init_valuer �statsZinput_methodr �get�sorted�operator� itemgetter)r r r r r �update( s z Plugin.updatec s t t| �j� dS )zUpdate stats views.N)r r �update_views)r )r r r r C s zPlugin.update_viewsc C s� g }t s| j s| j� r|S |d }djd|d�}|j| j|d�� djd�}|j| j|�� xh| jD ]^}|j| j� � dj|d d |� |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 )r r Zis_disabled�format�appendZcurse_add_lineZcurse_new_line�str)r r Z max_width�retZname_max_width�msg�ir r r � msg_curseH s zPlugin.msg_curse)NN)NN) �__name__� __module__�__qualname__�__doc__r r r Z_check_decoratorZ_log_result_decoratorr r r% � __classcell__r r )r r r s r c @ sT e Zd ZdZdZdd� Zdd� Zdd� Zd d � Zdd� Z d d� Z dd� Zdd� ZdS )r z This class manages the IRQ file.z/proc/interruptsc C s i | _ | j� dS )zPInit the class. The stat are stored in a internal list of dict N)�lasts�reset)r r r r r k s zGlancesIRQ.__init__c C s g | _ d| _dS )zReset the stats.r N)r � cpu_number)r r r r r, s s zGlancesIRQ.resetc C s | j � S )zReturn the current IRQ stats.)�_GlancesIRQ__update)r r r r r x s zGlancesIRQ.getc C s dS )zReturn the key of the dict.r r )r r r r r | s zGlancesIRQ.get_keyc C s t |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 �liner r r Z__header� s zGlancesIRQ.__headerc C s6 |j � }|d jdd�}|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_liner r r r Z__humanname� s zGlancesIRQ.__humannamec C sF |j � }y ttt|d| jd � ��}W n tk r@ d}Y nX |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 r4 r )r0 �sum�map�intr- � ValueError)r r1 r8 r"