Пример #1
0
 def _get_crash_report_row(self, crash_id: str, site_id: str) -> Optional[Dict[str, str]]:
     rows = CrashReportsRowTable().get_crash_report_rows(
         only_sites=[config.SiteId(ensure_str(site_id))],
         filter_headers="Filter: id = %s" % livestatus.lqencode(crash_id))
     if not rows:
         return None
     return rows[0]
Пример #2
0
 def _get_crash_report_row(self, crash_id, site_id):
     # type: (Text, Text) -> Optional[Dict[Text, Text]]
     rows = CrashReportsRowTable().get_crash_report_rows(
         only_sites=[config.SiteId(bytes(site_id))],
         filter_headers="Filter: id = %s" % livestatus.lqencode(crash_id))
     if not rows:
         return None
     return rows[0]
Пример #3
0
    def get_crash_report_rows(self, only_sites: Optional[List[config.SiteId]],
                              filter_headers: str) -> List[Dict[str, str]]:

        # First fetch the information that is needed to query for the dynamic columns (crash_info,
        # ...)
        crash_infos = self._get_crash_report_info(only_sites, filter_headers)
        if not crash_infos:
            return []

        rows = []
        for crash_info in crash_infos:
            file_path = "/".join(
                [crash_info["crash_type"], crash_info["crash_id"]])

            headers = ["crash_info"]
            columns = [
                "file:crash_info:%s/crash.info" %
                livestatus.lqencode(file_path)
            ]

            if crash_info["crash_type"] == "check":
                headers += ["agent_output", "snmp_info"]
                columns += [
                    "file:agent_output:%s/agent_output" %
                    livestatus.lqencode(file_path),
                    "file:snmp_info:%s/snmp_info" %
                    livestatus.lqencode(file_path),
                ]

            try:
                sites.live().set_prepend_site(False)
                sites.live().set_only_sites(
                    [config.SiteId(ensure_str(crash_info["site"]))])

                raw_row = sites.live().query_row(
                    "GET crashreports\n"
                    "Columns: %s\n"
                    "Filter: id = %s" %
                    (" ".join(columns),
                     livestatus.lqencode(crash_info["crash_id"])))
            finally:
                sites.live().set_only_sites(None)
                sites.live().set_prepend_site(False)

            crash_info.update(dict(zip(headers, raw_row)))
            rows.append(crash_info)

        return rows