Skip to content

User friendly nagios exit function #1

@JensTimmerman

Description

@JensTimmerman

Is a more user friendly nagios exit function needed or not?
It can be cumbersome to import all exit function or all nagsio tuple constants. a more easy to use wrapper can solve this.

def nagios_exit(state, message):
    """Print message according to state: supported states:
        - defined nagios constants NAGIOS_EXIT_
        - string: OK,WARNING,CRITICAL and UNKNOWN
        - integer: 0,1,2,3
    """
    nagios_states = [NAGIOS_EXIT_OK, NAGIOS_EXIT_WARNING, NAGIOS_EXIT_CRITICAL, NAGIOS_EXIT_UNKNOWN]
    for x in nagios_states:
        if state == x or state == x[0]  or state == x[1]:
            # this exits, no break or return needed
            _real_exit(message, x)
    log.raiseException('Unsupported state %s.' % (state))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions