コード例 #1
0
 def __get_text(self, colorize=False):
     summary = ""
     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)):
             summary += "The lowest and highest total count of glocks in all the snapshots.\n"
             summary += "%s\n\n" %(tableize(glocks_stats_totals_table,
                                            ["Hostname", "Filesystem", "Glock Total Count", "Time Occurred"],
                                            colorize=colorize).strip())
     for snapshot in self.get_snapshots():
         glocks_stats = snapshot.get_glocks_stats()
         formatted_table = tableize(glocks_stats.get_table(), ["Glock States"] +
                                    glocktop_analyze.glocks_stats.GLOCK_STATES, colorize=colorize).rstrip()
         if (colorize):
             summary += "Glock stats at %s for filesystem: " %(ColorizeConsoleText.orange(
                 glocks_stats.get_date_time().strftime("%Y-%m-%d %H:%M:%S")))
             summary += "%s\n%s\n\n" %(ColorizeConsoleText.orange(
                 self.get_filesystem_name()), formatted_table)
         else:
              summary += "Glock stats at %s for filesystem: " %(glocks_stats.get_date_time().strftime("%Y-%m-%d %H:%M:%S"))
              summary += "%s\n%s\n\n" %(self.get_filesystem_name(), formatted_table)
     if (summary):
         return "%s: %s\n\n%s\n" %(self.get_title(), self.get_description(), summary.strip())
     return ""
コード例 #2
0
    def analyze(self):
        for snapshot in self.get_snapshots():
            glocks_stats = snapshot.get_glocks_stats()
            formatted_table = tableize(glocks_stats.get_table(), ["Glock States"] +
                                       glocktop_analyze.glocks_stats.GLOCK_TYPES, colorize=True).rstrip()

            if (self.__gs_glocks_total_lowest == None):
                self.__gs_glocks_total_lowest = glocks_stats
            elif (glocks_stats.get_glocks_count() <= self.__gs_glocks_total_lowest.get_glocks_count()):
                self.__gs_glocks_total_lowest = glocks_stats

            if (self.__gs_glocks_total_highest == None):
                self.__gs_glocks_total_highest = glocks_stats
            elif (glocks_stats.get_glocks_count() >= self.__gs_glocks_total_highest.get_glocks_count()):
                self.__gs_glocks_total_highest = glocks_stats

        if (not self.__gs_glocks_total_highest == None):
            if (self.__gs_glocks_total_highest.get_glocks_count() >
                self.get_option("high_glocks_count_total")):
                try:
                    locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
                except locale.Error:
                    # Set default
                    locale.setlocale(locale.LC_ALL, '')
                high_glocks_count_total_comma = locale.format('%d', self.get_option("high_glocks_count_total"), True)
                # Call filesystem "all filesystems" since glocks stats is for
                # all filesystems and do not want duplicates.
                warning_msg =  "The number of total glocks on a snaphot of ALL gfs2 filesystem "
                warning_msg += "exceeded: %s." %(high_glocks_count_total_comma)
                self.add_warning(Admonition(snapshot.get_hostname(), "all filesystems", "Glocks",
                                            warning_msg,
                                            "https://access.redhat.com/solutions/1603713"))
コード例 #3
0
ファイル: pids.py プロジェクト: sbradley7777/glocktop_analyze
    def __get_text(self, colorize=False):
        summary = ""
        if (self.__pids_in_snapshots):
            summary += "\nThe number of times a pid appeared in a snapshot.\n"
            summary += "%s\n\n" %(tableize(self.__pids_in_snapshots,
                                           ["Filesystem", "Pid", "Command",
                                            "Number of Snapshots Appeared in"], colorize).strip())

        if (self.__pids_using_multiple_glocks):
            summary += "The glocks the pids appears in queue as holder or waiter.\n"
            summary += "%s\n\n" %(tableize(self.__pids_using_multiple_glocks,
                                           ["Filesystem", "Pid", "Command",
                                            "Number of Glocks Appeared in",
                                            "Glock Type/Inode"], colorize).strip())
        if (summary):
            summary =  "%s: %s\n\n%s\n" %(self.get_title(), self.get_description(), summary.strip())
        return summary
コード例 #4
0
 def __get_text(self, colorize=False):
     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]])
     if (table):
         return "%s: %s\n\n%s\n%s\n" %(self.get_title(), self.get_description(),
                                       "Glocks that appeared in at least %d snapshots." %(self.__minimum_glocks_in_snapshots),
                                       tableize(table, ["Hostname", "Filesystem Name", "Glock Type/Glocks Inode",
                                                        "Number of Snapshots Appeared in"], colorize=colorize).strip())
コード例 #5
0
    def __get_text(self, colorize=False):
        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()])
        if (table):
            return "%s: %s\n\n%s\n%s\n" %(self.get_title(), self.get_description(),
                                          "Glocks with demoting of a glocks taking greater than 0 seconds to complete.",
                                          tableize(table,["Filesystem", "Glock", "Demote Seconds"],
                                                   colorize=colorize).strip())

        return ""
コード例 #6
0
    def __get_text(self, colorize=False):
        summary = ""
        if (self.get_snapshots()):
            snapshots_summary = tableize([[self.get_hostname(), self.get_filesystem_name(),
                                           str(self.__snapshot_count), self.__start_time,
                                           self.__stop_time]],
                                         ["Hostname", "Filesystem", "Snapshots",
                                          "Start Time", "Stop Time"], colorize=colorize).strip()
            if (snapshots_summary):
                summary += "\nThen number of snapshots taken, start time, and end time.\n%s\n" %(snapshots_summary)
        if (self.__dlm_activity):
            dlm_activity_summary = tableize(self.__dlm_activity, ["Hostname", "Filesystem",
                                                                  "Snapshot Time",
                                                                  "Number of DLM Waiters"],
                                            colorize=colorize).strip()
            if (dlm_activity_summary):
                summary += "\nThe snapshots that contained at least 1 DLM waiter.\n%s\n" %(dlm_activity_summary)

        if (summary):
            return "%s: %s\n%s\n" %(self.get_title(), self.get_description(), summary)
        return ""
コード例 #7
0
 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())
コード例 #8
0
    def __get_text(self, colorize=False):
        summary = ""
        snapshots_table = []
        dlm_activity_table = []
        glocks_stats_totals_table = []
        for hostname in self.get_hostnames():
            if self.get_snapshots(hostname):
                snapshots_table.append(
                    [
                        hostname,
                        self.get_filesystem_name(),
                        str(self.__snapshot_count_for_hosts.get(hostname)),
                        str(self.__start_time_for_hosts.get(hostname)),
                        str(self.__stop_time_for_hosts.get(hostname)),
                    ]
                )

            if self.__dlm_activity_for_hosts.has_key(hostname):
                dlm_activity_table += self.__dlm_activity_for_hosts.get(hostname)
            if self.__gs_glocks_total_lowest.has_key(hostname) and self.__gs_glocks_total_highest.has_key(hostname):
                glocks_stats_totals_table += self.__get_glocks_count_table(
                    hostname, self.__gs_glocks_total_lowest.get(hostname), self.__gs_glocks_total_highest.get(hostname)
                )

        if snapshots_table:
            summary += "Snapshots Taken Start and Stop Time\n"
            summary += "%s\n\n" % (
                tableize(
                    snapshots_table, ["Hostname", "Filesystem", "Snapshots", "Start Time", "Stop Time"], colorize
                ).strip()
            )
        if glocks_stats_totals_table:
            summary += "The lowest and highest glock totals for all filesystems\n"
            summary += "%s\n\n" % (
                tableize(
                    glocks_stats_totals_table,
                    ["Hostname", "Filesystem", "Snapshot Time", "Glock Total Count"],
                    colorize=colorize,
                ).strip()
            )

        if dlm_activity_table:
            sorted_dlm_activity_table = sorted(dlm_activity_table, key=lambda d: d[2], reverse=False)
            summary += "Snapshots with DLM Activity\n"
            summary += "%s\n\n" % (
                tableize(
                    sorted_dlm_activity_table,
                    ["Hostname", "Filesystem", "Snapshot Time", "Number of DLM Waiters"],
                    colorize,
                ).strip()
            )
        # Group the snapshots together based on time snapshot taken.
        grouped_snapshots = self.get_snapshots_by_group()
        group_count_sorted = grouped_snapshots.keys()
        group_count_sorted.sort()
        snapshots_table_by_group = ""
        for group_count in group_count_sorted:
            gsnapshots = grouped_snapshots.get(group_count)
            gtable = []
            for gsnapshot in gsnapshots:
                gtable.append([gsnapshot.get_hostname(), gsnapshot.get_filesystem_name(), gsnapshot.get_date_time()])
            snapshots_table_by_group += (
                "%s\n\n" % (tableize(gtable, ["Hostname", "Filesystem", "Snapshot Time"], colorize)).strip()
            )
        if snapshots_table_by_group:
            summary += "Snapshots Grouped by Time Snapshot Taken\n%s" % (snapshots_table_by_group)
        return summary
コード例 #9
0
 def __str__(self):
     return tableize(self.get_table(), ["Glock States"] + GLOCK_STATES, colorize=False).rstrip()