%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/beacons/ |
Current File : //usr/lib/python2.7/site-packages/salt/beacons/diskusage.pyc |
� ���^c @@ s� d Z d d l m Z m Z d d l Z d d l Z d d l Z y d d l Z e Z Wn e k ro e Z n Xe j e � Z d Z d � Z d � Z d � Z d S( uT Beacon to monitor disk usage. .. versionadded:: 2015.5.0 :depends: python-psutil i ( t absolute_importt unicode_literalsNu diskusagec C@ s t t k r t St Sd S( N( t HAS_PSUTILt Falset __virtualname__( ( ( s: /usr/lib/python2.7/site-packages/salt/beacons/diskusage.pyt __virtual__ s c C@ s# t | t � s t d f St d f S( u+ Validate the beacon configuration u2 Configuration for diskusage beacon must be a list.u Valid beacon configuration( t isinstancet listR t True( t config( ( s: /usr/lib/python2.7/site-packages/salt/beacons/diskusage.pyt validate$ s c C@ s� t j d t � } g } xk| D]c} t t | � � } | } | j d � s^ d j | � } n t j j j � r� t j d d | � } t j d d | � } | j � } n x� | D]� } t j | | j � r� | j } y t j | � } Wn$ t k r t j d | � q� n X| j } | | } d | k rEt j d d | � } n t | � } | | k r~| j i | d 6| d 6� q~q� q� Wq W| S( u Monitor the disk usage of the minion Specify thresholds for each disk and only emit a beacon if any of them are exceeded. .. code-block:: yaml beacons: diskusage: - /: 63% - /mnt/nfs: 50% Windows drives must be quoted to avoid yaml syntax errors .. code-block:: yaml beacons: diskusage: - interval: 120 - 'c:\\': 90% - 'd:\\': 50% Regular expressions can be used as mount points. .. code-block:: yaml beacons: diskusage: - '^\/(?!home).*$': 90% - '^[a-zA-Z]:\\$': 50% The first one will match all mounted disks beginning with "/", except /home The second one will match disks from A:\ to Z:\ on a Windows system Note that if a regular expression are evaluated after static mount points, which means that if a regular expression matches another defined mount point, it will override the previously defined threshold. t allu $u {0}$u :\\\$u :\\\\u :\\\\\$u %s is not a valid mount point.u %u u diskusageu mount( t psutilt disk_partitionsR t nextt itert endswitht formatt saltt utilst platformt is_windowst ret subt uppert matcht mountpointt disk_usaget OSErrort logt warningt percentt floatt append( R t partst rett mountst mountt mount_ret partt _mountt _current_usaget current_usaget monitor_usage( ( s: /usr/lib/python2.7/site-packages/salt/beacons/diskusage.pyt beacon/ s6 ) )( t __doc__t __future__R R t loggingR t salt.utils.platformR R R R t ImportErrorR t getLoggert __name__R R R R R, ( ( ( s: /usr/lib/python2.7/site-packages/salt/beacons/diskusage.pyt <module> s