Anons79 Mini Shell

Directory : /proc/self/root/lib/python2.7/site-packages/ansible/plugins/callback/
Upload File :
Current File : //proc/self/root/lib/python2.7/site-packages/ansible/plugins/callback/nrdp.pyc

�
�Udac@`s�ddlmZmZmZeZdZddlZddlZddl	m
Z
ddlmZddl
mZdefd��YZdS(	i(tabsolute_importtdivisiontprint_functions)
    callback: nrdp
    type: notification
    author: "Remi VERCHERE (@rverchere)"
    short_description: post task result to a nagios server through nrdp
    description:
        - this callback send playbook result to nagios
        - nagios shall use NRDP to recive passive events
        - the passive check is sent to a dedicated host/service for ansible
    version_added: 2.8
    options:
        url:
            description: url of the nrdp server
            required: True
            env:
                - name : NRDP_URL
            ini:
                - section: callback_nrdp
                  key: url
        validate_certs:
            description: (bool) validate the SSL certificate of the nrdp server. (For HTTPS url)
            env:
                - name: NRDP_VALIDATE_CERTS
            ini:
                - section: callback_nrdp
                  key: validate_nrdp_certs
                - section: callback_nrdp
                  key: validate_certs
            default: False
            aliases: [ validate_nrdp_certs ]
        token:
            description: token to be allowed to push nrdp events
            required: True
            env:
                - name: NRDP_TOKEN
            ini:
                - section: callback_nrdp
                  key: token
        hostname:
            description: hostname where the passive check is linked to
            required: True
            env:
                - name : NRDP_HOSTNAME
            ini:
                - section: callback_nrdp
                  key: hostname
        servicename:
            description: service where the passive check is linked to
            required: True
            env:
                - name : NRDP_SERVICENAME
            ini:
                - section: callback_nrdp
                  key: servicename
N(t	urlencode(topen_url(tCallbackBasetCallbackModulecB`steZdZdZdZdZeZdZdZ	dZ
dZd�Zd
d
d
d	�Zd
�Zd�Zd�ZRS(sD
    send ansible-playbook to Nagios server using nrdp protocol
    g@tnotificationtnrdpiiiicC`s2tt|�j�t|_d|_d|_dS(N(tsuperRt__init__tFalsetprinted_playbooktNonet
playbook_nametplay(tself((sA/usr/lib/python2.7/site-packages/ansible/plugins/callback/nrdp.pyR
Ys		cC`s�tt|�jd|d|d|�|jd�|_|jjd�s[|jd7_n|jd�|_|jd�|_|jd�|_|jd	�|_	|jp�|jp�|jp�|jdkr�|jjd
�t
|_ndS(Nt	task_keystvar_optionstdirectturlt/ttokenthostnametservicenametvalidate_certss�NRDP callback wants the NRDP_URL, NRDP_TOKEN, NRDP_HOSTNAME, NRDP_SERVICENAME environment variables'. The NRDP callback plugin is disabled.(R	Rtset_optionst
get_optionRtendswithRRRtvalidate_nrdp_certsR
t_displaytwarningtTruetdisabled(RRRR((sA/usr/lib/python2.7/site-packages/ansible/plugins/callback/nrdp.pyR`s%cC`s�d}|d7}|d7}|d|j7}|d|j7}|d|7}|d|7}|d7}|d	7}id
d6|jd6t|�d
6}y8t|jdt|�ddd|j�}|j�SWn,t	k
r�}|j
jdj|��nXdS(s�
        nrpd service check send XMLDATA like this:
        <?xml version='1.0'?>
            <checkresults>
                <checkresult type='service'>
                    <hostname>somehost</hostname>
                    <servicename>someservice</servicename>
                    <state>1</state>
                    <output>WARNING: Danger Will Robinson!|perfdata</output>
                </checkresult>
            </checkresults>
        s<?xml version='1.0'?>
s<checkresults>
s<checkresult type='service'>
s<hostname>%s</hostname>
s<servicename>%s</servicename>
s<state>%d</state>
s<output>%s</output>
s</checkresult>
s</checkresults>
tsubmitchecktcmdRtXMLDATAtdatatmethodtPOSTRs$NRDP callback cannot send result {0}N(
RRRtbytesRRRRtreadt	ExceptionRRtformat(Rtstatetmsgtxmldatatbodytresponsetex((sA/usr/lib/python2.7/site-packages/ansible/plugins/callback/nrdp.pyt
_send_nrdpts*





cC`s
||_dS(s:
        Display Playbook and play start messages
        N(R(RR((sA/usr/lib/python2.7/site-packages/ansible/plugins/callback/nrdp.pytv2_playbook_on_play_start�sc
C`s
|j}d}t|jj��}d}}x}|D]u}|j|�}|d||d||d||d||df7}||d7}||d7}||d7}q5Wd||f}	|r�|j|j|	�n/|r�|j|j|	�n|j|j|	�d	S(
s8
        Display info about playbook statistics
        tisU'%s_ok'=%d '%s_changed'=%d                        '%s_unreachable'=%d '%s_failed'=%d toktchangedtunreachabletfailuress%s | %sN(	Rtsortedt	processedtkeyst	summarizeR2tCRITICALtWARNINGtOK(
RtstatstnametgstatsthoststcriticalRthosttstatR-((sA/usr/lib/python2.7/site-packages/ansible/plugins/callback/nrdp.pytv2_playbook_on_stats�s&	

N(t__name__t
__module__t__doc__tCALLBACK_VERSIONt
CALLBACK_TYPEt
CALLBACK_NAMER tCALLBACK_NEEDS_WHITELISTR?R>R=tUNKNOWNR
R
RR2R3RG(((sA/usr/lib/python2.7/site-packages/ansible/plugins/callback/nrdp.pyRIs		&	(t
__future__RRRttypet
__metaclass__t
DOCUMENTATIONtostjsont+ansible.module_utils.six.moves.urllib.parseRtansible.module_utils.urlsRtansible.plugins.callbackRR(((sA/usr/lib/python2.7/site-packages/ansible/plugins/callback/nrdp.pyt<module>s8

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]