Exemplo n.º 1
0
 def test_basic_logging_log(self):
     sys.stdout = StringIO()
     self._collector = Collector()
     sh = StreamHandler(sys.stdout)
     sh.setFormatter(defaultFormatter)
     shinken_logger.handlers = []
     shinken_logger.addHandler(sh)
     shinken_logger.load_obj(self._collector)
     shinken_logger.setLevel(DEBUG)
     self.generic_tst(lambda x: naglog_result('info', x), 'Some log-message',
                      [1, 1], [r'^\[\d+\] Some log-message\n$', r'^\[\d+\] Some log-message$'])
Exemplo n.º 2
0
    def check_and_log_activation_change(self):
        now = int(time.time())

        was_active = self.is_active
        self.is_active = self.is_time_valid(now)

        # If we got a change, log it!
        if self.is_active != was_active:
            _from = 0
            _to = 0
            # If it's the start, get a special value for was
            if was_active is None:
                _from = -1
            if was_active:
                _from = 1
            if self.is_active:
                _to = 1

            # Now raise the log
            naglog_result("info", "TIMEPERIOD TRANSITION: %s;%d;%d" % (self.get_name(), _from, _to))
Exemplo n.º 3
0
 def test_basic_logging_log(self):
     sys.stdout = StringIO()
     self._collector = Collector()
     sh = StreamHandler(sys.stdout)
     sh.setFormatter(defaultFormatter)
     shinken_logger.handlers = []
     shinken_logger.addHandler(sh)
     shinken_logger.load_obj(self._collector)
     shinken_logger.setLevel(DEBUG)
     self.generic_tst(
         lambda x: naglog_result('info', x), 'Some log-message', [1, 1],
         [r'^\[\d+\] Some log-message\n$', r'^\[\d+\] Some log-message$'])
Exemplo n.º 4
0
    def check_and_log_activation_change(self):
        now = int(time.time())

        was_active = self.is_active
        self.is_active = self.is_time_valid(now)

        # If we got a change, log it!
        if self.is_active != was_active:
            _from = 0
            _to = 0
            # If it's the start, get a special value for was
            if was_active is None:
                _from = -1
            if was_active:
                _from = 1
            if self.is_active:
                _to = 1

            # Now raise the log
            naglog_result('info', 'TIMEPERIOD TRANSITION: %s;%d;%d'
                                % (self.get_name(), _from, _to))
Exemplo n.º 5
0
 def test_basic_logging_log(self):
     sys.stdout = StringIO()
     self._collector = Collector()
     sh = StreamHandler(sys.stdout)
     sh.setFormatter(defaultFormatter)
     shinken_logger.handlers = []
     shinken_logger.addHandler(sh)
     shinken_logger.load_obj(self._collector)
     logfile = NamedTemporaryFile("w", delete=False)
     logfile.close()
     self.logfile_name = logfile.name
     shinken_logger.register_local_log(logfile.name)
     shinken_logger.setLevel(DEBUG)
     self.generic_tst(lambda x: naglog_result('info', x), 'Some log-message',
                      [1, 1, 1], ['', r'^\[\d+\] Some log-message$', r'^\[\d+\] Some log-message$'])
Exemplo n.º 6
0
 def test_basic_logging_log(self):
     sys.stdout = StringIO()
     self._collector = Collector()
     sh = StreamHandler(sys.stdout)
     sh.setFormatter(defaultFormatter)
     shinken_logger.handlers = []
     shinken_logger.addHandler(sh)
     shinken_logger.load_obj(self._collector)
     logfile = NamedTemporaryFile("w", delete=False)
     logfile.close()
     self.logfile_name = logfile.name
     shinken_logger.register_local_log(logfile.name)
     shinken_logger.setLevel(DEBUG)
     self.generic_tst(
         lambda x: naglog_result('info', x), 'Some log-message', [1, 1, 1],
         ['', r'^\[\d+\] Some log-message$', r'^\[\d+\] Some log-message$'])
Exemplo n.º 7
0
 def raise_cancel_downtime_log_entry(self):
     naglog_result(
         'info', "CONTACT DOWNTIME ALERT: %s;CANCELLED; Scheduled "
         "downtime for contact has been cancelled." % self.get_name())
Exemplo n.º 8
0
 def raise_exit_downtime_log_entry(self):
     naglog_result(
         'info', "CONTACT DOWNTIME ALERT: %s;STOPPED; Contact has "
         "exited from a period of scheduled downtime" % self.get_name())
Exemplo n.º 9
0
 def raise_enter_downtime_log_entry(self):
     naglog_result(
         'info', "CONTACT DOWNTIME ALERT: %s;STARTED; Contact has "
         "entered a period of scheduled downtime" % self.get_name())
Exemplo n.º 10
0
 def raise_cancel_downtime_log_entry(self):
     naglog_result('info', "CONTACT DOWNTIME ALERT: %s;CANCELLED; Scheduled "
                         "downtime for contact has been cancelled."
                         % self.get_name())
Exemplo n.º 11
0
 def raise_exit_downtime_log_entry(self):
     naglog_result('info', "CONTACT DOWNTIME ALERT: %s;STOPPED; Contact has "
                         "exited from a period of scheduled downtime"
                         % self.get_name())
Exemplo n.º 12
0
 def raise_enter_downtime_log_entry(self):
     naglog_result('info', "CONTACT DOWNTIME ALERT: %s;STARTED; Contact has "
                         "entered a period of scheduled downtime"
                         % self.get_name())