%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/nagios_rpc.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZddlm	Z	ddl
Zeje�Z
d�Zd�Zddd�Zdd�Zddd	�ZdS(
uT
Check Host & Service status from Nagios via JSON RPC.

.. versionadded:: 2015.8.0

i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrorcC@sdS(u8
    Only load if requests is successfully imported
    u
nagios_rpc((((s;/usr/lib/python2.7/site-packages/salt/modules/nagios_rpc.pyt__virtual__scC@s�tdd�ptdd�}|s5td��ntdd�pRtdd�}tdd�prtdd�}i|d	6|d
6|d6S(u@
    Get configuration items for URL, Username and Password
    u
config.getunagios.status_urlunagios:status_urlu(Missing Nagios URL in the configuration.unagios.usernameunagios:usernameunagios.passwordunagios:passworduurluusernameupassword(t__salt__R(t
status_urltusernametpassword((s;/usr/lib/python2.7/site-packages/salt/modules/nagios_rpc.pyt_config sc
C@st�}d}i|d6|d6}itd6}|rCd|d<n|rV||d<n|dr�|ddk	r�|d|df}nd}yYtjjj|d	d
dd|d
td|dtdtdid|dddt�
}	Wn&t	k
rd|d<t|d<|SX|	j
dd�tjjj
jjkrsy|	d|d<t|d<Wq�t	k
rod|d<q�Xn�|	j
dd�tjjj
jjkr�d|d<nW|	j
dd�tjjj
jjkr�dj|d	�|d<ndj|	j�|d<|S(u%
    Send query along to Nagios.
    uhostnameuqueryuresultu	enumerateu
formatoptionsuservicedescriptionuusernameupassworduurltmethoduGETtparamstdecodetdatattexttstatustheader_dicttauthtbackendurequeststoptsu Please ensure Nagios is running.uerrorustatusudictu	json_datau6Authentication failed. Please check the configuration.uURL {0} was not found.uResults: {0}N(R	tNonetFalsetsalttutilsthttptquerytTruet__opts__t
ValueErrortgettexttsixtmovesthttp_clienttOKtUNAUTHORIZEDt	NOT_FOUNDtformatR(
Rthostnamet	enumeratetservicetconfigR
RtretRtresult((s;/usr/lib/python2.7/site-packages/salt/modules/nagios_rpc.pyt
_status_query4sV	








'
'
'cK@s�|std��nd}|jd�}t||d|�}i|dd6}|dr�|jdi�jdi�j|i�jd|r�d	p�d
�|d<n|d|d<|S(uU
    Check status of a particular host By default
    statuses are returned in a numeric format.

    Parameters:

    hostname
        The hostname to check the status of the service in Nagios.

    numeric
        Turn to false in order to return status in text format
        ('OK' instead of 0, 'Warning' instead of 1 etc)

    :return: status:     'OK', 'Warning', 'Critical' or 'Unknown'

    CLI Example:

    .. code-block:: bash

        salt '*' nagios_rpc.host_status hostname=webserver.domain.com
        salt '*' nagios_rpc.host_status hostname=webserver.domain.com numeric=False
    uMissing hostname parameteruhostunumericR'uresultu	json_dataudataustatusuUnknowniuerror(RRR,(R&tkwargsttargettnumericR
R*((s;/usr/lib/python2.7/site-packages/salt/modules/nagios_rpc.pythost_statusqs
-cK@s�|std��n|s*td��nd}|jd�}t||d|d|�}i|dd6}|dr�|jdi�jd	i�j|i�jd
|r�dp�d�|d
<n|d
|d
<|S(u�
    Check status of a particular service on a host on it in Nagios.
    By default statuses are returned in a numeric format.

    Parameters:

    hostname
        The hostname to check the status of the service in Nagios.

    service
        The service to check the status of in Nagios.

    numeric
        Turn to false in order to return status in text format
        ('OK' instead of 0, 'Warning' instead of 1 etc)

    :return: status:     'OK', 'Warning', 'Critical' or 'Unknown'

    CLI Example:

    .. code-block:: bash

        salt '*' nagios_rpc.service_status hostname=webserver.domain.com service='HTTP'
        salt '*' nagios_rpc.service_status hostname=webserver.domain.com service='HTTP' numeric=False
    uMissing hostname parameteruMissing service parameteruserviceunumericR(R'uresultu	json_dataudataustatusuUnknowniuerror(RRR,(R&R(R-R.R/R
R*((s;/usr/lib/python2.7/site-packages/salt/modules/nagios_rpc.pytservice_status�s
-(t__doc__t
__future__RRRtloggingtsalt.ext.six.moves.http_clientRtsalt.exceptionsRtsalt.utils.httpt	getLoggert__name__tlogRR	RR,R0R1(((s;/usr/lib/python2.7/site-packages/salt/modules/nagios_rpc.pyt<module>s		=(

Zerion Mini Shell 1.0