Пример #1
0
    def __init__(self, config, nagios_cfg, **kwargs):
        """Read given Nagios config file and load tests"""

        cfg = nagios_objects.ConfigParser(nagios_cfg,
                ('object_cache_file', 'status_file',
                 'command_file', 'check_result_path'))
        self._nagios_obj = cfg['object_cache_file']
        spool = nagios_api.spool_path(cfg['check_result_path'], 'nagcat')
        self._nagios_cmd = nagios_api.NagiosCommander(
                cfg['command_file'], spool)

        self._status_file = cfg['status_file']
        self._status_cache = None
        self._status_mtime = 0

        log.info("Using Nagios object cache: %s", self._nagios_obj)
        log.info("Using Nagios command file: %s", cfg['command_file'])
        log.info("Using Nagios status file: %s", self._status_file)
        return super(NagcatNagios, self).__init__(config, **kwargs)
Пример #2
0
    def __init__(self, config, nagios_cfg, **kwargs):
        """Read given Nagios config file and load tests"""

        # TODO: The NagcatNagios class needs to be easier to test,
        # that way we can actually call the __init__ for it in unit tests
        # and test NagcatMerlin and NagcatNagios more effectively.
        # More specifically, nagios_cfg currently *has* to be a file,
        # which makes unit testing extraordinarily difficult.
        cfg = nagios_objects.ConfigParser(nagios_cfg,
                ('object_cache_file', 'status_file',
                 'command_file', 'check_result_path'))
        self._nagios_obj = cfg['object_cache_file']
        spool = nagios_api.spool_path(cfg['check_result_path'], 'nagcat')
        self._nagios_cmd = nagios_api.NagiosCommander(
                cfg['command_file'], spool)

        self._status_file = cfg['status_file']
        self._status_cache = None
        self._status_mtime = 0

        log.info("Using Nagios object cache: %s", self._nagios_obj)
        log.info("Using Nagios command file: %s", cfg['command_file'])
        log.info("Using Nagios status file: %s", self._status_file)
        return super(NagcatNagios, self).__init__(config, **kwargs)