Beispiel #1
0
    def test_exit_from_errorcode(self):
        """test calling the correct exit function."""

        for (ec, expected) in [
                (0, NAGIOS_EXIT_OK),
                (1, NAGIOS_EXIT_WARNING),
                (2, NAGIOS_EXIT_CRITICAL),
                (3, NAGIOS_EXIT_UNKNOWN),
                (101, NAGIOS_EXIT_UNKNOWN),
                ]:
            try:
                exit_from_errorcode(ec, "boem")
            except SystemExit as err:
                print err
                self.assertTrue(err.code == expected[0])
Beispiel #2
0
    def test_exit_from_errorcode(self):
        """test calling the correct exit function."""

        for (ec, expected) in [
            (0, NAGIOS_EXIT_OK),
            (1, NAGIOS_EXIT_WARNING),
            (2, NAGIOS_EXIT_CRITICAL),
            (3, NAGIOS_EXIT_UNKNOWN),
            (101, NAGIOS_EXIT_UNKNOWN),
        ]:
            try:
                exit_from_errorcode(ec, "boem")
            except SystemExit as err:
                print(err)
                self.assertTrue(err.code == expected[0])
Beispiel #3
0
 def unknown(self, msg):
     """
     Convenience method that exists with nagios unknown exitcode
     """
     exit_from_errorcode(3, msg)
Beispiel #4
0
 def critical(self, msg):
     """
     Convenience method that exists with nagios critical exitcode
     """
     exit_from_errorcode(2, msg)
Beispiel #5
0
 def warning(self, msg):
     """
     Convenience method exists with nagios warning exitcode
     """
     exit_from_errorcode(1, msg)
Beispiel #6
0
 def ok(self, msg):
     """
     Convenience method that exists with nagios OK exitcode
     """
     exit_from_errorcode(0, msg)
Beispiel #7
0
 def critical_exception(self, msg, exception):
     """
     Convenience method: report exception and critical method
     """
     logging.exception("%s: %s", msg, exception)
     exit_from_errorcode(2, msg)