????

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

3

Eo�cY	�@sLdZddlmZmZddlmZddlmZddlm	Z	Gdd�de	�Z
dS)	a
SystemV AMP
===========

Monitor the state of the System V init system and service.

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

Running: Number of running services.
Stopped: Number of stopped services.
Upstart: Number of service managed by Upstart.

Source reference: http://askubuntu.com/questions/407075/how-to-read-service-status-all-results

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

[amp_systemv]
# Systemv
enable=true
regex=\/sbin\/init
refresh=60
one_line=true
service_cmd=/usr/bin/service --status-all
�)�check_output�STDOUT)�logger)�	iteritems)�
GlancesAmpc@s,eZdZdZdZdZdZdZdZdd�Z	d	S)
�AmpzGlances' Systemd AMP.ZSystemVz1.0z&Get services list from service (initd)Z	Nicolargozcontact@nicolargo.comc
CsBtjdj|j|jd���y t|jd�j�td�jd�}Wn6t	k
rp}ztjdj|j|��WYdd}~Xn�Xdddd�}x�|jd	�D]r}|j�}t
|�d
kr�q�|ddkr�|d
d7<q�|ddkr�|dd7<q�|ddkr�|dd7<q�Wd}x&t|�D]\}}	|dj||	�7}�qW|j|dd�|j
�S)zUpdate the AMPz!{}: Update stats using service {}Zservice_cmd)�stderrzutf-8z&{}: Error while executing service ({})Nr)�running�stopped�upstart�
���+r	�-r
�?rz	Services
z{}: {}
� )Z	separator)r�debug�format�NAME�getr�splitr�decode�OSError�lenrZ
set_result�result)
�selfZprocess_list�res�eZstatus�r�l�output�k�v�r$�%/usr/lib/python3.6/glances_systemv.py�update9s* &z
Amp.updateN)
�__name__�
__module__�__qualname__�__doc__r�VERSIONZDESCRIPTIONZAUTHORZEMAILr&r$r$r$r%r,srN)r*�
subprocessrrZglances.loggerrZglances.compatrZglances.amps.glances_amprrr$r$r$r%�<module>#s