????

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_systemd.cpython-36.pyc

3

Eo�c
�@sPdZddlmZmZddlmZddlmZmZddl	m
Z
Gdd�de
�ZdS)	a�
Systemd AMP
===========

Monitor the state of the systemd system and service (unit) manager.

How to read the stats
---------------------

active: Number of active units. This is usually a fairly basic way to tell if the
unit has started successfully or not.
loaded: Number of loaded units (unit's configuration has been parsed by systemd).
failed: Number of units with an active failed status.

Source reference: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units

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

[amp_systemd]
# Systemd
enable=true
regex=\/usr\/lib\/systemd\/systemd
refresh=60
one_line=true
systemctl_cmd=/usr/bin/systemctl --plain
�)�check_output�CalledProcessError)�logger)�	iteritems�to_ascii)�
GlancesAmpc@s,eZdZdZdZdZdZdZdZdd�Z	d	S)
�AmpzGlances' Systemd AMP.ZSystemdz1.0z*Get services list from systemctl (systemd)Z	Nicolargozcontact@nicolargo.comcCs4tjdj|j|jd���yt|jd�j��}Wn:ttfk
rj}ztjdj|j|��WYdd}~Xn�Xi}x�t	|�jd�dd
�D]f}|j�}t
|�dkr�xLtdd�D]>}y|||d7<Wq�tk
r�d|||<Yq�Xq�Wq�Wd	}x&t
|�D]\}	}
|d
j|	|
�7}�qW|j|dd�|j�S)zUpdate the AMPz#{}: Update stats using systemctl {}Z
systemctl_cmdz({}: Error while executing systemctl ({})N�
���z	Services
z{}: {}
� )Z	separatori����)r�debug�format�NAME�getr�split�OSErrorrr�len�range�KeyErrorrZ
set_result�result)�selfZprocess_list�res�eZstatus�r�column�c�output�k�v�r!�%/usr/lib/python3.6/glances_systemd.py�update:s&&z
Amp.updateN)
�__name__�
__module__�__qualname__�__doc__r�VERSIONZDESCRIPTIONZAUTHORZEMAILr#r!r!r!r"r-srN)r'�
subprocessrrZglances.loggerrZglances.compatrrZglances.amps.glances_amprrr!r!r!r"�<module>$s