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 ""
def __print_plugins_description():
    plugins =  __get_plugins([], "", {}, [], False)
    plugins += __get_plugins({}, "", {}, [], True)
    plugins_str = ""
    for plugin in plugins:
        plugins_str += "  %s: %s\n" %(ColorizeConsoleText.red(plugin.get_name()), plugin.get_description())
    if (plugins_str):
        print "The plugins installed are:"
        print plugins_str.rstrip()
    else:
        message = "There was no plugins found."
        logging.getLogger(glocktop_analyze.MAIN_LOGGER_NAME).error(message)
        sys.exit()
    options_str = ""
    for plugin in plugins:
        if (hasattr(plugin, "OPTIONS")):
            for option in plugin.OPTIONS:
                option_name = "  %s.%s" %(plugin.get_name(), option[0])
                options_str += "%s: %s (Default=%s)\n" %(ColorizeConsoleText.red(option_name),
                                                         option[1], str(option[2]))
    if (options_str):
        print "\nThe plugin options that can be configured are:"
        print options_str.rstrip()
 def __get_text(self, colorize=False):
     # Need to add warning:
     summary = ""
     for pidglocks_in_snapshot in self.__glocks_dependencies_snapshots:
         snapshot_summary = ""
         # Review all the glocks for a particular pid.
         for pidglocks in pidglocks_in_snapshot.get_pidglocks():
             pid_summary = ""
             glock_holder_flag_found = 0
             glocks = pidglocks.get_glocks()
             if (len(glocks) >= self.__minimum_glocks_dep):
                 for glock in glocks:
                     pid_summary += "    %s\n" %(glock)
                     for h in glock.get_holders():
                         pid_summary += "      %s\n" %(h)
                     glock_object = glock.get_glock_object()
                     if (not glock_object == None):
                         pid_summary += "      %s\n" %(glock_object)
                     if (not glock.get_glock_holder() == None):
                         glock_holder_flag_found += 1
                 if (pid_summary):
                     pid_header =  "  pid: %s command: %s | " %(pidglocks.get_pid(), pidglocks.get_command())
                     pid_header += "%d glocks associated with pid " %(len(pidglocks.get_glocks()))
                     pid_header += "(%d glock holders)\n" %(glock_holder_flag_found)
                     if (colorize):
                         pid_header = ColorizeConsoleText.orange(pid_header)
                     snapshot_summary += "%s%s\n" %(pid_header, pid_summary)
         if (snapshot_summary):
             snapshot_header = "%s - %s @%s" %(pidglocks_in_snapshot.get_filesystem_name(),
                                               pidglocks_in_snapshot.get_date_time(),
                                               pidglocks_in_snapshot.get_hostname())
             if (colorize):
                 snapshot_header =  ColorizeConsoleText.red(snapshot_header)
             summary += "%s\n%s\n\n" %(snapshot_header, snapshot_summary.strip())
     if (summary):
         summary = "%s: %s\n%s" %(self.get_title(), self.get_description(), summary)
     return summary
 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())
Exemple #5
0
 def __get_text(self, colorize=False):
     summary = ""
     for snapshot in self.get_snapshots():
         current_summary = ""
         glocks = snapshot.get_glocks()
         for glock in glocks:
             glock_holders = glock.get_holders()
             if (len(glock_holders) >= self.__mininum_waiter_count):
                 current_summary += "  %s\n" %(glock)
                 for holder in glock_holders:
                     current_summary += "     %s\n" %(holder)
                 if (not glock.get_glock_object() == None):
                     current_summary += "     %s\n" %(glock.get_glock_object())
         if (current_summary):
             current_summary_title = str(snapshot)
             if (colorize):
                 current_summary_title = ColorizeConsoleText.red(str(snapshot))
             summary += "%s\n%s\n" %(current_summary_title, current_summary)
     if (summary):
         return "%s: %s\n%s" %(self.get_title(), self.get_description(),
                               summary.rstrip("----------------"))
     return ""