示例#1
0
    def write(self, html_format=False):
        wdata = ""
        path_to_output_file = ""
        if (not html_format):
            wdata = self.__get_text(colorize=False)
            filename = "%s.txt" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
            path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                            self.get_filesystem_name()), filename)

        else:
            filename = "%s.html" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
            path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                            self.get_filesystem_name()), filename)
            bdata = self.__get_html(colorize=True)
            if (bdata):
                wdata = "%s\n%s\n<BR/><HR/><BR/>%s" %(generate_css_header(), bdata, generate_footer())


        if (wdata):
            if (not write_to_file(path_to_output_file, wdata, append_to_file=False, create_file=True)):
                message = "An error occurred writing to the file: %s" %(path_to_output_file)
                logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)
        raw_data = self.__get_raw()
        if (raw_data):
            filename = "%s-raw.txt" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
            path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                            self.get_filesystem_name()), filename)
            if (not write_to_file(path_to_output_file, "%s\n" %(raw_data),
                                  append_to_file=False, create_file=True)):
                message = "An error occurred writing to the file: %s" %(path_to_output_file)
                logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)
    def write(self, html_format=False):
        wdata = ""
        filename = ""
        if (not html_format):
            filename = "%s.txt" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
            wdata = self.__get_text(colorize=False)
        else:
            bdata = ""
            filename = "%s.html" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
            if ((not self.__gs_glocks_total_lowest == None) or
                (not self.__gs_glocks_total_highest == None)):
                glocks_stats_totals_table = self.__get_glocks_count_table()
                if (len(glocks_stats_totals_table)):
                    title = "The lowest and highest total count of glocks in all the snapshots."
                    bdata += generate_table(glocks_stats_totals_table,
                                            ["Hostname", "Filesystem", "Time Occurred", "Glock Total Count"],
                                            title=title,
                                            description="")
            for snapshot in self.get_snapshots():
                glocks_stats = snapshot.get_glocks_stats()
                title =  "Glock stats at %s for filesystem: %s" %(glocks_stats.get_date_time().strftime("%Y-%m-%d %H:%M:%S"),
                                                                   self.get_filesystem_name())
                bdata += generate_table(glocks_stats.get_table(),
                                        ["-"] + GLOCK_TYPES,
                                        title=title,
                                        description="")
            if (bdata):
                wdata = "%s\n%s\n%s" %(generate_css_header(include_css_table=True), bdata, generate_footer())

        if (wdata):
            path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                            self.get_filesystem_name()), filename)
            if (not write_to_file(path_to_output_file, wdata, append_to_file=False, create_file=True)):
                message = "An error occurred writing to the file: %s" %(path_to_output_file)
                logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)
 def write(self, html_format=False):
     if (self.__glocks_high_demote_seconds):
         wdata = ""
         path_to_output_file = ""
         if (not html_format):
             filename = "%s.txt" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
             path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                             self.get_filesystem_name()), filename)
             wdata = self.__get_text(colorize=False)
         else:
             filename = "%s.html" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
             path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                             self.get_filesystem_name()), filename)
             table = []
             for hashkey in self.__glocks_high_demote_seconds.keys():
                 table.append([self.get_filesystem_name(), hashkey, self.__glocks_high_demote_seconds.get(hashkey).strip()])
             bdata = generate_table(table,
                                    ["Filesystem", "Glock", "Demote Seconds"],
                                    title=self.get_title(),
                                    description="Glocks that took longer than 0 seconds to demote a glock")
             wdata = "%s\n%s\n%s" %(generate_css_header(include_css_table=True), bdata, generate_footer())
         if (wdata):
             if (not write_to_file(path_to_output_file, wdata, append_to_file=False, create_file=True)):
                 message = "An error occurred writing to the file: %s" %(path_to_output_file)
                 logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)
    def write(self, html_format=False):
        if (self.__glocks_in_snapshots):
            wdata = ""
            path_to_output_file = ""
            if (not html_format):
                filename = "%s.txt" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
                path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                                self.get_filesystem_name()), filename)
                wdata = self.__get_text(colorize=False)

            else:
                filename = "%s.html" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
                path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                                self.get_filesystem_name()), filename)
                table = []
                for pair in sorted(self.__glocks_in_snapshots.items(), key=itemgetter(1), reverse=True):
                    if (pair[1] >= self.__minimum_glocks_in_snapshots):
                        table.append([self.get_hostname(), self.get_filesystem_name(), pair[0], pair[1]])
                bdata = generate_table(table,
                                       ["Hostname", "Filesystem Name", "Glock Type/Glocks Inode",
                                        "Number of Snapshots Appeared in"],
                                       title=self.get_title(),
                                       description="The number of times that a glock appeared in a snapshot.")
                wdata = "%s\n%s\n%s" %(generate_css_header(include_css_table=True), bdata, generate_footer())
            if (wdata):
                if (not write_to_file(path_to_output_file, wdata, append_to_file=False, create_file=True)):
                    message = "An error occurred writing to the file: %s" %(path_to_output_file)
                    logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)
    def write(self, html_format=False):
        wdata =""
        path_to_output_file = ""
        if (not html_format):
            filename = "%s.txt" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
            path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                            self.get_filesystem_name()), filename)
            wdata = self.__get_text(colorize=False)
        else:
            bdata = ""
            if (self.__snapshot_count > 0):
                bdata += generate_table([[self.get_hostname(), self.get_filesystem_name(), str(self.__snapshot_count),
                                          self.__start_time, self.__stop_time]],
                                        ["Hostname", "Filesystem", "Snapshots", "Start Time", "Stop Time"],
                                        title="Snapshots Taken",
                                        description="The number of snapshots taken and the time that first and the last snapshot taken.")

            if (self.__dlm_activity):
                bdata += generate_table(self.__dlm_activity,
                                        ["Hostname", "Filesystem", "Snapshot Time", "Number of DLM Waiters"],
                                        title="DLM Waiter Count",
                                        description="The number of DLM waiters for a snapshot. Only snapshots with DLM waiter count higher than 0 displayed.")
            if (bdata):
                wdata = "%s\n%s\n%s" %(generate_css_header(include_css_table=True), bdata, generate_footer())
                filename = "%s.html" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
                path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                            self.get_filesystem_name()), filename)
        if (wdata):
            if (not write_to_file(path_to_output_file, wdata, append_to_file=False, create_file=True)):
                message = "An error occurred writing to the file: %s" %(path_to_output_file)
                logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)
def __output_warnings(warnings, path_to_output_dir, disable_std_out=True, html_format=False):
    if (warnings):
        sorted_warnings = []
        # Remove the duplicates that are found.
        for warning in warnings:
            if (not warning in sorted_warnings):
                sorted_warnings.append(warning)
        sorted_warnings = sorted(sorted_warnings, key=lambda x: x.get_filesystem_name(), reverse=False)
        def get_warning_text(warnings, colorize=False):
            warnings_table = []
            for warning in warnings:
                uri = "-"
                if (warning.get_uri()):
                    uri = warning.get_uri()
                warnings_table += [[warning.get_hostname(),
                                    warning.get_filesystem_name(),
                                    warning.get_type(),
                                    warning.get_description(),
                                    uri]]
            header = "Warnings Found:"
            if (warnings_table and colorize):
                header = ColorizeConsoleText.red("%s" %(header))
            return "\n\n%s\n%s\n" %(header, tableize(warnings_table,
                                                 ["Hostname", "Filesystem",
                                                  "Type", "Description",
                                                  "Link to Article"],
                                                 colorize=colorize).strip())

        if (not disable_std_out):
            print get_warning_text(sorted_warnings, colorize=True)
        # Write warnings to text file or html file
        wdata = "%s\n" %(get_warning_text(sorted_warnings, colorize=False).strip())
        path_to_output_file = os.path.join(path_to_output_dir, "warnings.txt")
        if (html_format):
            path_to_output_file = os.path.join(path_to_output_dir, "warnings.html")
            bdata = ""
            warnings_table = []
            for warning in sorted_warnings:
                uri = "-"
                if (warning.get_uri()):
                    uri = warning.get_uri()
                warnings_table += [[warning.get_hostname(),
                                    warning.get_filesystem_name(),
                                    warning.get_type(),
                                    warning.get_description(),
                                    uri]]
                bdata = generate_table(warnings_table,
                                       ["Hostname", "Filesystem",
                                        "Type", "Description",
                                        "Link to Article"],
                                       title="Warnings",
                                       description="The following is a list of potential issues found:")
                wdata = "%s\n%s\n%s" %(generate_css_header(include_css_table=True), bdata, generate_footer())
        if (wdata):
            if (not write_to_file(path_to_output_file, wdata, append_to_file=False, create_file=True)):
                message = "An error occurred writing the file: %s" %(path_to_output_file)
                logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)
示例#7
0
 def write(self, html_format=False):
     if (not html_format):
         wdata = self.__get_text(colorize=False)
         if (wdata):
             filename = "%s.txt" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
             path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                             self.get_filesystem_name()), filename)
             if (not write_to_file(path_to_output_file, wdata, append_to_file=False, create_file=True)):
                 message = "An error occurred writing to the file: %s" %(path_to_output_file)
                 logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)
     else:
         bdata = ""
         if (self.__pids_in_snapshots):
             bdata += generate_table(self.__pids_in_snapshots,
                                     ["Filesystem", "Pid", "Command", "Number of Snapshots Appeared in"],
                                     title="Pids Appearing in Multiple Snapshots",
                                     description="The pids that appeared in multiple snapshots.")
         if (self.__pids_using_multiple_glocks):
             bdata += generate_table(self.__pids_using_multiple_glocks,
                                     ["Filesystem", "Pid", "Command", "Number of Glocks Appeared in", "Glock Type/Inode"],
                                     title="Pids that Appeared in Multiple Glocks.",
                                     description="The pids that appeared in multiple glocks.")
         if (bdata):
             wdata = "%s\n%s\n%s" %(generate_css_header(include_css_table=True), bdata, generate_footer())
             filename = "%s.html" %(self.get_title().lower().replace(" - ", "-").replace(" ", "_"))
             path_to_output_file = os.path.join(os.path.join(self.get_path_to_output_dir(),
                                                                 self.get_filesystem_name()), filename)
             if (not write_to_file(path_to_output_file, wdata, append_to_file=False, create_file=True)):
                 message = "An error occurred writing to the file: %s" %(path_to_output_file)
                 logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).debug(message)