%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/beacons/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/beacons/service.pyo

�
���^c@@s�dZddlmZmZddlZddlZddlZddlmZej	e
�ZiZdZ
d�Zd�ZdS(u%
Send events covering service status
i(tabsolute_importtunicode_literalsN(tmapuservicecC@s�t|t�stdfSi}tt|j|��d|krKtdfSx3|dD]'}t|d|t�sVtdfSqVWtdfS(u+
    Validate the beacon configuration
    u0Configuration for service beacon must be a list.uservicesu3Configuration for service beacon requires services.u@Configuration for service beacon must be a list of dictionaries.uValid beacon configuration(t
isinstancetlisttFalseRtupdatetdicttTrue(tconfigt_configtconfig_item((s8/usr/lib/python2.7/site-packages/salt/beacons/service.pytvalidates

c	C@s�g}i}tt|j|��xh|jdi�D]T}i}|d|}itd|�d6||<||d<||d<tj�}|s�i}nd|kr�t|d<nd|kr�t|d<nd|kr�t|d<nd	|kr�d
|d	<nd|krK||drK|d}tj	j
|�r:tnt||d<nd|kr||dtkr||tkr�||t|<|d	d
kr�|t|d<q�|ds�q5q�|j|�nt|d||dkr||t|<|d	d
kr
|t|d<q|j|�ndt|kr�t
t|t|d��}||d	kryt|d=|j|�qyq�q5|j|�q5W|S(
us	
    Scan for the configured services and fire events

    Example Config

    .. code-block:: yaml

        beacons:
          service:
            - services:
                salt-master: {}
                mysql: {}

    The config above sets up beacons to check for
    the salt-master and mysql services.

    The config also supports two other parameters for each service:

    `onchangeonly`: when `onchangeonly` is True the beacon will fire
    events only when the service status changes.  Otherwise, it will fire an
    event at each beacon interval.  The default is False.

    `delay`: when `delay` is greater than 0 the beacon will fire events only
    after the service status changes, and the delay (in seconds) has passed.
    Applicable only when `onchangeonly` is True.  The default is 0.

    `emitatstartup`: when `emitatstartup` is False the beacon will not fire
    event when the minion is reload. Applicable only when `onchangeonly` is True.
    The default is True.

    `uncleanshutdown`: If `uncleanshutdown` is present it should point to the
    location of a pid file for the service.  Most services will not clean up
    this pid file if they are shutdown uncleanly (e.g. via `kill -9`) or if they
    are terminated through a crash such as a segmentation fault.  If the file is
    present, then the beacon will add `uncleanshutdown: True` to the event.  If
    not present, the field will be False.  The field is only added when the
    service is NOT running. Omitting the configuration variable altogether will
    turn this feature off.

    Please note that some init systems can remove the pid file if the service
    registers as crashed. One such example is nginx on CentOS 7, where the
    service unit removes the pid file when the service shuts down (IE: the pid
    file is observed as removed when kill -9 is sent to the nginx master
    process). The 'uncleanshutdown' option might not be of much use there,
    unless the unit file is modified.

    Here is an example that will fire an event 30 seconds after the state of nginx
    changes and report an uncleanshutdown.  This example is for Arch, which
    places nginx's pid file in `/run`.

    .. code-block:: yaml

        beacons:
          service:
            - services:
                nginx:
                  onchangeonly: True
                  delay: 30
                  uncleanshutdown: /run/nginx.pid
    uservicesuservice.statusurunninguservice_nameutaguoncleanshutdownu
emitatstartupuonchangeonlyudelayiuuncleanshutdownutime(RRRtgett__salt__ttimeRRtostpathtexiststLAST_STATUStappendtinttround(	R	tretR
tservicetret_dicttservice_configtcurrtimetfilenametelapsedtime((s8/usr/lib/python2.7/site-packages/salt/beacons/service.pytbeacon,sV=

	




)
(t__doc__t
__future__RRRtloggingRtsalt.ext.six.movesRt	getLoggert__name__tlogRt__virtualname__RR(((s8/usr/lib/python2.7/site-packages/salt/beacons/service.pyt<module>s	

Zerion Mini Shell 1.0