%PDF- %PDF-
| Direktori : /proc/self/root/proc/3522530/root/usr/lib/python2.7/site-packages/salt/beacons/ |
| Current File : //proc/self/root/proc/3522530/root/usr/lib/python2.7/site-packages/salt/beacons/haproxy.pyo |
�
���^c @@ sl d Z d d l m Z m Z d d l Z d d l m Z e j e � Z d Z
d � Z d � Z d � Z
d S( u�
Watch current connections of haproxy server backends.
Fire an event when over a specified threshold.
.. versionadded:: 2016.11.0
i ( t absolute_importt unicode_literalsN( t mapu haproxyc C@ s% d t k r t St j d � t Sd S( u@
Only load the module if haproxyctl module is installed
u haproxy.get_sessionsu Not loading haproxy beaconN( t __salt__t __virtualname__t logt debugt False( ( ( s8 /usr/lib/python2.7/site-packages/salt/beacons/haproxy.pyt __virtual__ s
c C@ s� t | t � s t d f Si } t t | j | � � d | k rK t d f St | d t � sh t d f Sxs | d D]g } t j d | d | � d | d | k r� t d f S| d | d } t | t � ss t d f Sqs Wt d f S(
u+
Validate the beacon configuration
u0 Configuration for haproxy beacon must be a list.u backendsu3 Configuration for haproxy beacon requires backends.u1 Backends for haproxy beacon must be a dictionary.u
_config %su serversu, Backends for haproxy beacon require servers.u* Servers for haproxy beacon must be a list.u Valid beacon configuration( t
isinstancet listR R t updatet dictR R t True( t configt _configt backendt _servers( ( s8 /usr/lib/python2.7/site-packages/salt/beacons/haproxy.pyt validate s
c C@ s� g } i } t t | j | � � x� | j d d � D]� } | d | } | d } x� | d D]~ } t d | | � } | r^ t | � t | � k r� i | d 6| d 6| d 6} t j d | | | | � | j | � q� q^ q^ Wq5 W| S( u�
Check if current number of sessions of a server for a specific haproxy backend
is over a defined threshold.
.. code-block:: yaml
beacons:
haproxy:
- backends:
www-backend:
threshold: 45
servers:
- web1
- web2
- interval: 120
u backendsu thresholdu serversu haproxy.get_sessionsu serveru scuru! Emit because %s > %s for %s in %s( ( R
R R t getR t intR R t append( R t retR R t backend_configt thresholdt servert scurt _server( ( s8 /usr/lib/python2.7/site-packages/salt/beacons/haproxy.pyt beacon>