%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.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlZddlm	Z	ej
e�ZdZ
d�Zddd	�Zd
�Zd�Zdd�Zddd
�Zdd�Zd�Zd�Zd�Zd�ZdS(uA
Run nagios plugins/checks from salt and get the return as data.
i(tabsolute_importtprint_functiontunicode_literalsN(tsixu/usr/lib/nagios/plugins/cC@s tjjt�rdStdfS(u3
    Only load if nagios-plugins are installed
    unagiosuOThe nagios execution module cannot be loaded: nagios-plugins are not installed.(tostpathtisdirt	PLUGINDIRtFalse(((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pyt__virtual__suucmd.retcodecC@sGi}t�}||krCt|djt||�dt�}n|S(u`
    Execute nagios plugin if it's in the directory with salt command specified in run_type
    u
{0}{1} {2}tpython_shell(tlist_pluginst__salt__tformatRR(tplugintargstrun_typetdatatall_plugins((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pyt_execute_cmds	c
C@s�td|�}i}x�|D]�}i||<||}xq|D]i}t|t�ruttj|��}||}n|}d}t||�}	|||�|||	<q>WqW|S(u]
    Run one or more nagios plugins from pillar data and get the result of run_type
    The pillar have to be in this format:
    ------
    webserver:
        Ping_google:
            - check_icmp: 8.8.8.8
            - check_icmp: google.com
        Load:
            - check_load: -w 0.8 -c 1
        APT:
            - check_apt
    -------
    u
pillar.getu(Rt
isinstancetdicttnextRtiterkeyst_format_dict_key(
tpillar_nameRtgroupsRtgrouptcommandstcommandRRtcommand_key((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pyt_execute_pillar,s




cC@s?|}|jdd�}|dkr;d|}||}n|S(Nu uu_(treplace(RRtkey_nametargs_key((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pyROs

cC@st||d�}|S(u�
    Run nagios plugin and return all the data execution with cmd.run

    CLI Example:

    .. code-block:: bash

        salt '*' nagios.run check_apt
        salt '*' nagios.run check_icmp '8.8.8.8'
    ucmd.run(R(RRR((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pytrunYscC@sRi}|dkr$t||�}ni||<t||d�}|||d<|S(uC
    Run one nagios plugin and return retcode of the execution
    ucmd.retcodeustatusN(tNoneRR(RRR!Rtstatus((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pytretcodeis
cC@st||d�}|S(uN
    Run nagios plugin and return all the data execution with cmd.run_all
    ucmd.run_all(R(RRR((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pytrun_all{scC@s!td|�}i}i}x�|D]�}||}x�|D]�}t|t�rqttj|��}||}n|}d}|jt|||��d}	t||d�}
||kr�t||d�}	n|
|	ks�||kr:||kri||<n|
||d<q:q:Wq#W|S(u�
    Run one or more nagios plugins from pillar data and get the result of cmd.retcode
    The pillar have to be in this format::

        ------
        webserver:
            Ping_google:
                - check_icmp: 8.8.8.8
                - check_icmp: google.com
            Load:
                - check_load: -w 0.8 -c 1
            APT:
                - check_apt
        -------

    webserver is the role to check, the next keys are the group and the items
    the check with the arguments if needed

    You must to group different checks(one o more) and always it will return
    the highest value of all the checks

    CLI Example:

    .. code-block:: bash

        salt '*' nagios.retcode webserver
    u
pillar.getuiustatus(	RRRRRRtupdateR&tint(RRtcheckRRRRRRt
current_valuet	new_value((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pytretcode_pillar�s*




cC@st|t�}|S(u�
    Run one or more nagios plugins from pillar data and get the result of cmd.run
    The pillar have to be in this format::

        ------
        webserver:
            Ping_google:
                - check_icmp: 8.8.8.8
                - check_icmp: google.com
            Load:
                - check_load: -w 0.8 -c 1
            APT:
                - check_apt
        -------

    webserver is the role to check, the next keys are the group and the items
    the check with the arguments if needed

    You have to group different checks in a group

    CLI Example:

    .. code-block:: bash

        salt '*' nagios.run webserver
    (RR#(RR((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pyt
run_pillar�scC@st|t�}|S(u�
    Run one or more nagios plugins from pillar data and get the result of cmd.run_all
    The pillar have to be in this format::

        ------
        webserver:
            Ping_google:
                - check_icmp: 8.8.8.8
                - check_icmp: google.com
            Load:
                - check_load: -w 0.8 -c 1
            APT:
                - check_apt
        -------

    webserver is the role to check, the next keys are the group and the items
    the check with the arguments if needed

    You have to group different checks in a group

    CLI Example:

    .. code-block:: bash

        salt '*' nagios.run webserver
    (RR'(RR((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pytrun_all_pillar�scC@srtjt�}g}xV|D]N}tjjt|�}tjtj|�tj@}|r|j|�qqW|S(uw
    List all the nagios plugins

    CLI Example:

    .. code-block:: bash

        salt '*' nagios.list_plugins
    (	RtlistdirRRtjointstattS_IXUSRtST_MODEtappend(tplugin_listtretRtstat_ftexecute_bit((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pyR�s

(t__doc__t
__future__RRRRR2tloggingtsalt.extRt	getLoggert__name__tlogRR	RRRR#R$R&R'R-R.R/R(((s7/usr/lib/python2.7/site-packages/salt/modules/nagios.pyt<module>s$			#	
	=	 	

Zerion Mini Shell 1.0