Example #1
0
 def test_format_num(self):
     """test various numbers with separator"""
     self.assertEqual(humanize.format_num(999), "999")
     self.assertEqual(humanize.format_num(1000), "1,000")
     self.assertEqual(humanize.format_num(1000000), "1,000,000")
     self.assertEqual(humanize.format_num(999.4), "999")
     self.assertEqual(humanize.format_num(1000.4), "1,000")
     self.assertEqual(humanize.format_num(1000000.4), "1,000,000")
Example #2
0
def test_format_num():
    """test various numbers with separator"""
    assert humanize.format_num(999) == "999"
    assert humanize.format_num(1000) == "1,000"
    assert humanize.format_num(1000000) == "1,000,000"
    assert humanize.format_num(999.4) == "999"
    assert humanize.format_num(1000.4) == "1,000"
    assert humanize.format_num(1000000.4) == "1,000,000"
Example #3
0
def format_table_stat(stat, val_suffix=""):
    """display most value read in a human friendly
    format with the responsible table and node"""
    if not stat or len(stat) < 3:
        return NA
    val_suffix_str = ""
    if val_suffix:
        val_suffix_str = "%s " % val_suffix
    node = stat[0]
    table = stat[1]
    val = stat[2]
    if node and table and val:
        return "%s %s(%s %s)" % (humanize.format_num(val), val_suffix_str,
                                 table, node)
    return NA
Example #4
0
 def print_summary(self):
     """ prints a summary report """
     self.analyze()
     summary = Summary(self.nodes)
     print("%s version: %s" % (self.command_name, VERSION))
     print('')
     print("Summary (%s lines)" % format_num(summary.lines))
     print("Summary (%s skipped lines)" % format_num(summary.skipped_lines))
     print('')
     print("dse versions: %s" % (set(summary.versions) or 'unknown'))
     print("cassandra versions: %s" %
           (set(summary.cassandra_versions) or 'unknown'))
     print("first log time: %s" % summary.start)
     print("last log time: %s" % summary.end)
     if not self.dumps_analyzed:
         print("Nothing found!")
         return
     print("duration: %s" %
           format_seconds(int(summary.duration.total_seconds())))
     print("total stages analyzed: %s" % self.dumps_analyzed)
     print("total nodes analyzed: %s" % len(summary.nodes))
     pauses = summary.get_pauses()
     if pauses:
         print('')
         percentiles = []
         percentiles.append(get_percentile_headers("GC pauses"))
         percentiles.append(["", "---", "---", "---", "---", "---", "---"])
         percentiles.append(get_percentiles("ms", pauses, strformat="%i"))
         pad_table(percentiles, min_width=11, extra_pad=2)
         for line in percentiles:
             print("".join(line))
         print("total GC events: %s" % len(pauses))
     print('')
     ops = summary.get_busiest_tables('ops')[:5]
     if ops:
         print("busiest tables by ops across all nodes")
         print('-' * 30)
         for onode, (oname, num) in ops:
             print("* %s: %s: %s" % (onode, oname, num))
         print('')
         print("busiest table by data across all nodes")
         print('-' * 30)
         for dnode, (dname, data) in summary.get_busiest_tables('data')[:5]:
             print("* %s: %s: %s" % (dnode, dname, data))
         print('')
     print("busiest stages across all nodes")
     print('-' * 30)
     data = []
     for (name, status, stage, value) in summary.get_busiest_stages():
         data.append(
             ["* %s %s:" % (stage, status),
              str(value),
              "(%s)" % name])
     pad_table(data, extra_pad=2)
     for line in data:
         print("".join(line))
     pending = summary.get_stages_in('pending')
     data = []
     if pending:
         data.append([])
         self.__print_stages('pending', pending, data)
     delayed = summary.get_stages_in('local backpressure')
     if delayed:
         data.append([])
         self.__print_backpressure(delayed, data)
     data.append([])
     pad_table(data, extra_pad=2)
     for line in data:
         print("".join(line))
     self.__print_recs()
Example #5
0
 def __repr__(self):
     return "%s ops / %s data" % (format_num(
         self.ops), format_bytes(self.data))
Example #6
0
    def print_histogram(self):
        """ print histogram report, analyzing if necessary """
        self.analyze()
        print("%s version: %s" % (self.command_name, VERSION))
        print('')
        print("Histogram")
        print('')
        if not self.nodes:
            print("Nothing found!")
            return

        for name, node in self.nodes.items():
            print(name)
            print('-' * 60)
            print("%s lines" % format_num(node.lines))
            print("%s skipped lines" % format_num(node.skipped_lines))
            print("dse version: %s" % (node.version or 'unknown'))
            print("cassandra version: %s" %
                  (node.cassandra_version or 'unknown'))
            print("log start time: %s" % node.start)
            print("log end time: %s" % node.end)
            if not node.dumps_analyzed:
                print("Nothing found!")
                continue
            print("duration: %s" %
                  format_seconds(int(node.duration().total_seconds())))
            print("stages analyzed: %s" % node.dumps_analyzed)
            if node.pauses:
                percentiles = [[]]
                percentiles.append(get_percentile_headers("GC pauses"))
                header = [""]
                header.extend(["---" for i in range(6)])
                percentiles.append(header)
                percentiles.append(
                    get_percentiles("ms", node.pauses, strformat="%i"))
                pad_table(percentiles, min_width=11, extra_pad=2)
                for line in percentiles:
                    print("".join(line))
                print("total GC events: %s" % len(node.pauses))
            print('')
            ops = node.get_busiest_tables('ops')[:5]
            if ops:
                print("busiest tables (ops)")
                print('-' * 30)
                nlen = max(len(o[0]) for o in ops)
                for n, t in ops:
                    print(n.ljust(nlen), t)
                data = node.get_busiest_tables('data')[:5]
                print("busiest tables (data)")
                print('-' * 30)
                nlen = max(len(d[0]) for d in data)
                for n, t in data:
                    print(n.ljust(nlen), t)
            print('')
            if node.stages:
                percentiles = []
                percentiles.append(get_percentile_headers('stages'))
                percentiles.append([])
                for status, stage in node.stages.items():
                    header = [status.upper()]
                    header.extend("" for i in range(6))
                    percentiles.append(header)
                    for tpname, vals in sorted(stage.items(),
                                               key=lambda tpool: max(tpool[1]),
                                               reverse=True):
                        percentiles.append(
                            get_percentiles(tpname, vals, strformat="%i"))
                    percentiles.append([])
                pad_table(percentiles, extra_pad=2)
                for line in percentiles:
                    print("".join(line))
        print('')
        self.__print_recs()