%PDF- %PDF-
| Direktori : /proc/self/root/proc/3522530/root/lib/python2.7/site-packages/salt/beacons/ |
| Current File : //proc/self/root/proc/3522530/root/lib/python2.7/site-packages/salt/beacons/network_info.pyo |
�
���^c @@ s� d Z d d l m Z m Z d d l Z y d d l j j Z e Z
Wn e k
r] e Z
n Xd d l
m Z e j e � Z d Z d d d d d
d d d
g Z d � Z d � Z d � Z d � Z d S( uQ
Beacon to monitor statistics from ethernet adapters
.. versionadded:: 2015.5.0
i ( t absolute_importt unicode_literalsN( t mapu network_infou
bytes_sentu
bytes_recvu packets_sentu packets_recvu errinu erroutu dropinu dropoutc C@ s@ i } x3 t D]+ } t | | � r
t | | � | | <q
q
W| S( u)
Convert snetinfo object to list
( t __attrst hasattrt getattr( t objt rett attr( ( s= /usr/lib/python2.7/site-packages/salt/beacons/network_info.pyt _to_list! s
c C@ s t s t d f St S( Nu5 cannot load network_info beacon: psutil not available( t
HAS_PSUTILt Falset __virtualname__( ( ( s= /usr/lib/python2.7/site-packages/salt/beacons/network_info.pyt __virtual__- s
c @ s� d d d d d d d d d g � t | t � s: t d
f Si } t t | j | � � xi | j d i � D]U } t | d | t � s� t d f St � f d
� | d | D� � si t d f Sqi Wt d f S( u+
Validate the beacon configuration
u typeu
bytes_sentu
bytes_recvu packets_sentu packets_recvu errinu erroutu dropinu dropoutu5 Configuration for network_info beacon must be a list.u
interfacesuE Configuration for network_info beacon must be a list of dictionaries.c 3@ s | ] } | � k Vq d S( N( ( t .0t j( t VALID_ITEMS( s= /usr/lib/python2.7/site-packages/salt/beacons/network_info.pys <genexpr>K s u3 Invalid configuration item in Beacon configuration.u Valid beacon configuration( t
isinstancet listR R t updatet gett dictt anyt True( t configt _configt item( ( R s= /usr/lib/python2.7/site-packages/salt/beacons/network_info.pyt validate3 s
$c
C@ s� g } i } t t | j | � � t j d t j � t j d t � } t j d | � xl| j d i � D]X} | | k rj | d | } | | } t } x� t
D]� } | | k r� d | k r� | d d k r� t | | d � t
| | � k r�t } q�q�d | k rc| d d k rct | | d � t
| | � k rDt } q�t j d t | | d � � q�t | | d � t
| | � k r�t } q�q� q� W| r�| j i | d 6t | � d
6� q�qj qj W| S( us
Emit the network statistics of this host.
Specify thresholds for each network stat
and only emit a beacon if any of them are
exceeded.
Emit beacon when any values are equal to
configured values.
.. code-block:: yaml
beacons:
network_info:
- interfaces:
eth0:
type: equal
bytes_sent: 100000
bytes_recv: 100000
packets_sent: 100000
packets_recv: 100000
errin: 100
errout: 100
dropin: 100
dropout: 100
Emit beacon when any values are greater
than configured values.
.. code-block:: yaml
beacons:
network_info:
- interfaces:
eth0:
type: greater
bytes_sent: 100000
bytes_recv: 100000
packets_sent: 100000
packets_recv: 100000
errin: 100
errout: 100
dropin: 100
dropout: 100
u psutil.net_io_counters %st pernicu _stats %su
interfacesu typeu equalu greateru attr %su interfaceu network_infoN( R R R t logt debugt psutilt net_io_countersR R R R R t Nonet intt appendR ( R R R t _statst interfacet interface_configt _if_statst _diffR ( ( s= /usr/lib/python2.7/site-packages/salt/beacons/network_info.pyt beaconQ s@ 0
( t __doc__t
__future__R R t loggingt salt.utils.psutil_compatt utilst
psutil_compatR R R
t ImportErrorR t salt.ext.six.movesR t getLoggert __name__R R R R R
R R) ( ( ( s= /usr/lib/python2.7/site-packages/salt/beacons/network_info.pyt <module> s"