????

Your IP : 3.143.168.178


Current Path : /lib/python3.6/site-packages/glances/amps/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/glances/amps/__pycache__/glances_default.cpython-36.pyc

3

Eo�c��@sTdZddlmZmZmZddlmZmZddlm	Z	ddl
mZGdd�de�ZdS)	a
Default AMP
=========

Monitor a process by executing a command line. This is the default AMP's behavior
if no AMP script is found.

Configuration file example
--------------------------

[amp_foo]
enable=true
regex=\/usr\/bin\/foo
refresh=10
one_line=false
command=foo status
�)�check_output�STDOUT�CalledProcessError)�u�to_ascii)�logger)�
GlancesAmpcs>eZdZdZdZdZdZdZdZd�fdd�	Z	d	d
�Z
�ZS)�AmpzGlances' Default AMP.�z1.1Z	Nicolargozcontact@nicolargo.comNcs"|j�|_tt|�j||d�dS)z
Init the AMP.)�name�argsN)�
capitalize�NAME�superr	�__init__)�selfrr)�	__class__��%/usr/lib/python3.6/glances_default.pyr,s
zAmp.__init__cCs tjdj|j|jd���y|jd�}Wn8tk
r`}ztjdj|j|��|j�Sd}~XnX|dkr�|jdjtdd�|D��td	d�|D����|j�SyFd
}x*|j	d�D]}|t
t|j	�td��7}q�W|jt
|j���Wn0tk
�r}z|j|j�WYdd}~XnX|j�S)
zUpdate the AMPz%{}: Update AMP stats using command {}Zservice_cmdZcommandz&{}: Error while executing command ({})NzCPU: {:.1f}% | MEM: {:.1f}%cSsg|]}|d�qS)Zcpu_percentr)�.0�prrr�
<listcomp>AszAmp.update.<locals>.<listcomp>cSsg|]}|d�qS)Zmemory_percentr)rrrrrrAsr
�;)�stderr)r�debug�formatr�get�OSError�resultZ
set_result�sum�splitrrrr�rstripr�output)rZprocess_list�res�e�msg�cmdrrr�update1s&&z
Amp.update)NN)�__name__�
__module__�__qualname__�__doc__r�VERSIONZDESCRIPTIONZAUTHORZEMAILrr'�
__classcell__rr)rrr	#sr	N)
r+�
subprocessrrrZglances.compatrrZglances.loggerrZglances.amps.glances_amprr	rrrr�<module>s