/usr/share/cagefs-skeleton/lib/python3.9/site-packages/glances/plugins/__pycache__
a ���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.9/site-packages/glances/plugins/glances_irq.pyr s zPlugin.__init__c C s | j �� S )zReturn the key of the list.)r �get_key�r r r r r $ s zPlugin.get_keyc C sZ | � � }ts| jS | jdkr(| j�� }n | jdkr2t|t�d�dd�dd� }|| _| jS )zUpdate the IRQ stats.�localZsnmp�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| ��� dS )zUpdate stats views.N)r r �update_viewsr r r r r C s zPlugin.update_viewsc C s� g }t r| jr| �� r|S |d }djd|d�}|�| �|d�� d�d�}|�| �|�� | jD ]^}|�| �� � dj|d d |� |d�}|�| �|�� d�t|d ��}|�| �|�� qb|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 | _ | �� dS )zPInit the class. The stat are stored in a internal list of dict N)�lasts�resetr r r r r k s zGlancesIRQ.__init__c C s g | _ d| _dS )zReset the stats.r N)r � cpu_numberr r r r r/ s s zGlancesIRQ.resetc C s | � � S )zReturn the current IRQ stats.)�_GlancesIRQ__updater 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 |�� �| _| 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�splitr0 )r �liner r r Z__header� s zGlancesIRQ.__headerc C s6 |� � }|d �dd�}|�� r2|d�|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_{}���)r3 �replace�isdigitr"