HEX
Server: LiteSpeed
System: Linux altar46.supremepanel46.com 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: jysa (4021)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //lib/python2.7/site-packages/pynag/Utils/states.pyc
�
�O�]c@@sUdZddlmZddlZd$\ZZZZd%\Z	Z
Zi
ed6ed6ed	6ed
6ed6ed6ed
6ed6ed6ed6ed6ed6ed6Zie	d6e
d6ed6e	d6e
d6ed6Z
ide6de6de6de6Zide	6de
6de6Zdejjfd��YZd �Zd!�Zd"�Zd#�ZdS(&sjConstants and convenience functions for host and service states.

Example usage:
    from pynag.Utils import states
    print states.OK, states.WARNING, states.CRITICAL, states.UNKNOWN

    print states.service_state_to_int('critical')
    print states.service_state_to_string(0)
    print states.host_state_to_int('UP')
    print states.host_state_to_string(1)
i(tabsolute_importNiiitoktwarningtcriticaltunknowntwarntcrittwtctut0t1t2t3tuptdowntunreachabletOKtWarningtCriticaltUnknowntUptDowntUnreachabletUnknownStatecB@seZdZRS(s9Raised when a state was inputed that we do not recognize.(t__name__t
__module__t__doc__(((s6/usr/lib/python2.7/site-packages/pynag/Utils/states.pyR?scC@sFt|�j�}yt|SWn!tk
rAtd|��nXdS(sqConverts from strings like OK to states like 0.

    Args:
        State: string. Can be in the form of 'ok', 'warning', 'critical', '1', etc.

    Returns:
        Integer. A nagios corresponding to the free text state inputted.

    Raises:
        UnknownState: If no match can be found for 'state'.

    Examples:
        >>> service_state_to_int('ok')
        0
        >>> service_state_to_int('Warning')
        1
        >>> service_state_to_int('critical')
        2
        >>> service_state_to_int('UNKNOWN')
        3
        >>> service_state_to_int('0')
        0
        >>> service_state_to_int('1')
        1
        >>> service_state_to_int('2')
        2
        >>> service_state_to_int('3')
        3
        >>> service_state_to_int('foo')
        Traceback (most recent call last):
          ..
        UnknownState: Do not know how to handle state foo

    s"Do not know how to handle state %sN(tstrtlowert_SERVICE_TEXT_TO_INTtKeyErrorR(tstatettext((s6/usr/lib/python2.7/site-packages/pynag/Utils/states.pytservice_state_to_intCs
#
cC@st|�}t|S(s:Converts from integer or text to a formal text representation of a nagios state.

    Args:
        State: integer or string. e.g. 0,1,2,3 or 'warn', 'crit'

    Returns:
        String. Formal description of a specified nagios state.

    Raises:
        UnknownState: If no match can be found for 'state'.

    Examples:
        >>> service_state_to_string(0)
        'OK'
        >>> service_state_to_string(1)
        'Warning'
        >>> service_state_to_string(2)
        'Critical'
        >>> service_state_to_string(3)
        'Unknown'
        >>> service_state_to_string('ok')
        'OK'
        >>> service_state_to_string('warn')
        'Warning'
        >>> service_state_to_string('foo')
        Traceback (most recent call last):
          ..
        UnknownState: Do not know how to handle state foo

    (R"t_SERVICE_INT_TO_TEXT(R tinteger((s6/usr/lib/python2.7/site-packages/pynag/Utils/states.pytservice_state_to_stringmscC@sFt|�j�}yt|SWn!tk
rAtd|��nXdS(s�Converts from strings like UP to states like 0.

    Args:
        State: string. Can be in the form of 'UP', 'Down', 'Unreachable', '1', etc.

    Returns:
        String. Formal description of a specified nagios state.

    Raises:
        UnknownState: If no match can be found for 'state'.

    Examples:
        >>> host_state_to_int('up')
        0
        >>> host_state_to_int('Down')
        1
        >>> host_state_to_int('UNREACHABLE')
        2
        >>> host_state_to_int(0)
        0
        >>> host_state_to_int(3)
        Traceback (most recent call last):
         ..
        UnknownState: Do not know how to handle state 3

    s"Do not know how to handle state %sN(RRt_HOST_TEXT_TO_INTRR(R R!((s6/usr/lib/python2.7/site-packages/pynag/Utils/states.pythost_state_to_int�s

cC@st|�}t|S(s9Converts from integer or text to a formal text representation of a nagios state.

    Args:
        State: string. Can be in the form of 'ok', 'warning', 'critical', '1', etc.

    Returns:
        Integer. A nagios corresponding to the free text state inputted.

    Raises:
        UnknownState: If no match can be found for 'state'.

    Examples:
        >>> host_state_to_string(0)
        'Up'
        >>> host_state_to_string(1)
        'Down'
        >>> host_state_to_string(2)
        'Unreachable'
        >>> host_state_to_string('DOWN')
        'Down'
    (R't_HOST_INT_TO_TEXT(R R$((s6/usr/lib/python2.7/site-packages/pynag/Utils/states.pythost_state_to_string�s(iiii(iii(Rt
__future__Rtpynag.errorstpynagRtWARNINGtCRITICALtUNKNOWNtUPtDOWNtUNREACHABLERR&R#R(terrorst
PynagErrorRR"R%R'R)(((s6/usr/lib/python2.7/site-packages/pynag/Utils/states.pyt<module>sN



	*	#	"