コード例 #1
0
    def test_search_filter_invert_match(self):
        with tempfile.NamedTemporaryFile(mode='w', delete=False) as ftmp:
            ftmp.write(FILTER_TEST_1)
            ftmp.close()
            s = FileSearcher()
            fd = FilterDef(r" (ERROR)", invert_match=True)
            s.add_filter_term(fd, path=ftmp.name)
            sd = SearchDef(r".+ INFO (.+)")
            s.add_search_term(sd, path=ftmp.name)
            results = s.search().find_by_path(ftmp.name)
            self.assertEqual(len(results), 1)
            for r in results:
                self.assertEqual(r.get(1), "blah")

            os.remove(ftmp.name)
コード例 #2
0
ファイル: agent_checks.py プロジェクト: nicolasbock/hotsos
    def __init__(self, *args, **kwargs):
        super().__init__(*args,
                         **kwargs,
                         master_results_key="neutron-ovs-agent")
        self.logs_path = os.path.join(constants.DATA_ROOT,
                                      SERVICE_RESOURCES["neutron"]["logs"])

        ovs_agent_base_log = 'neutron-openvswitch-agent.log'
        self.ovs_agent_data_source = os.path.join(self.logs_path,
                                                  f'{ovs_agent_base_log}')
        if constants.USE_ALL_LOGS:
            self.ovs_agent_data_source = f"{self.ovs_agent_data_source}*"

        # the logs we are looking for are INFO only
        fd = FilterDef(" INFO ")
        self.searchobj.add_filter_term(fd, self.ovs_agent_data_source)
コード例 #3
0
ファイル: agent_checks.py プロジェクト: freyes/hotsos
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs,
                         master_results_key="neutron-l3-agent")
        self.logs_path = os.path.join(constants.DATA_ROOT,
                                      SERVICE_RESOURCES["neutron"]["logs"])

        l3_agent_base_log = 'neutron-l3-agent.log'
        self.l3_agent_data_source = os.path.join(self.logs_path,
                                                 f'{l3_agent_base_log}')
        if constants.USE_ALL_LOGS:
            self.l3_agent_data_source = f"{self.l3_agent_data_source}*"

        self._l3_agent_info = {}

        # the logs we are looking for are DEBUG/INFO only
        fd = FilterDef(" (INFO|DEBUG) ")
        self.searchobj.add_filter_term(fd, self.l3_agent_data_source)
コード例 #4
0
    def _add_exception_searches(self):
        for svc, exprs in self._exception_exprs.items():
            logpath = SERVICE_RESOURCES[svc]["logs"]
            data_source_template = os.path.join(constants.DATA_ROOT, logpath,
                                                '{}.log')
            if constants.USE_ALL_LOGS:
                data_source_template = "{}*".format(data_source_template)

            for agent in SERVICE_RESOURCES[svc]["daemons"]:
                data_source = data_source_template.format(agent)
                fd = FilterDef(r"( ERROR | WARNING |Traceback)")
                self.searchobj.add_filter_term(fd, data_source)
                for subexpr in exprs + self._agent_issues.get(svc, []):
                    # NOTE: services running under apache have their logs
                    # prepending with a load of apache/mod_wsgi info so we have
                    # to do this way to account for both. We ignore the apache
                    # prefix and it will not count towards the result.
                    expr = (r"^(?:\[[\w :\.]+\].+\]\s+)?([0-9\-]+) (\S+) "
                            ".+{}.*".format(subexpr))
                    sd = SearchDef(expr, tag=agent, hint=subexpr)
                    self.searchobj.add_search_term(sd, data_source)
コード例 #5
0
ファイル: ovs_checks.py プロジェクト: dosaboy/hotsos
    def register_search_terms(self):
        path = os.path.join(constants.DATA_ROOT,
                            OVS_DAEMONS[self.daemon]["logs"])
        if constants.USE_ALL_LOGS:
            path = f"{path}*"

        fd = FilterDef(r"ERROR|WARN")
        self.search_obj.add_filter_term(fd, path)

        tag = "netdev_linux-no-such-device"
        sd = SearchDef(r"([0-9-]+)T([0-9:\.]+)Z.+\|(\S+): .+: No such device",
                       tag=tag)
        self.tags.append(tag)
        self.search_obj.add_search_term(sd, path)

        tag = "bridge-no-such-device"
        sd = SearchDef(
            r"([0-9-]+)T([0-9:\.]+)Z.+\|could not open network "
            r"device (\S+) \(No such device\)",
            tag=tag)
        self.tags.append(tag)
        self.search_obj.add_search_term(sd, path)
コード例 #6
0
ファイル: agent_checks.py プロジェクト: freyes/hotsos
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs,
                         master_results_key="neutron-ovs-agent")
        self.logs_path = os.path.join(constants.DATA_ROOT,
                                      SERVICE_RESOURCES["neutron"]["logs"])

        ovs_agent_base_log = 'neutron-openvswitch-agent.log'
        self.ovs_agent_data_source = os.path.join(self.logs_path,
                                                  f'{ovs_agent_base_log}')
        if constants.USE_ALL_LOGS:
            # FIXME: disabling this for now since running against a long
            # history of logs can generate a very large amount of data that can
            # consume too much memory.
            msg = ("\nINFO: disabling --all-logs for openstack rpc_loop "
                   "checks since it can result in excessive memory "
                   "consumption\n")
            sys.stderr.write(msg)
            # self.ovs_agent_data_source = f"{self.ovs_agent_data_source}*"

        # the logs we are looking for are INFO only
        fd = FilterDef(" rpc_loop ")
        self.searchobj.add_filter_term(fd, self.ovs_agent_data_source)