<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[15680] CalendarServer/trunk/calendarserver/tools/dashtime.py</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/15680">15680</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2016-06-17 06:51:36 -0700 (Fri, 17 Jun 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Add per-line zlib decompress. Per-host plots are now scaled so that each host plot has the same y-axis range for easier comparison.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkcalendarservertoolsdashtimepy">CalendarServer/trunk/calendarserver/tools/dashtime.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkcalendarservertoolsdashtimepy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/calendarserver/tools/dashtime.py (15679 => 15680)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/calendarserver/tools/dashtime.py        2016-06-17 00:26:21 UTC (rev 15679)
+++ CalendarServer/trunk/calendarserver/tools/dashtime.py        2016-06-17 13:51:36 UTC (rev 15680)
</span><span class="lines">@@ -20,6 +20,7 @@
</span><span class="cx">
</span><span class="cx"> from bz2 import BZ2File
</span><span class="cx"> from collections import OrderedDict, defaultdict
</span><ins>+from zlib import decompress
</ins><span class="cx"> import argparse
</span><span class="cx"> import json
</span><span class="cx"> import matplotlib.pyplot as plt
</span><span class="lines">@@ -65,6 +66,13 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><ins>+ def getMaxY(measurement, numHosts):
+ if "-" in measurement:
+ measurement = measurement.split("-", 1)[0]
+ return DataType.allTypes[measurement].maxY(numHosts)
+
+
+ @staticmethod
</ins><span class="cx"> def skip(measurement):
</span><span class="cx"> if "-" in measurement:
</span><span class="cx"> measurement = measurement.split("-", 1)[0]
</span><span class="lines">@@ -86,7 +94,7 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><del>- def maxY(stats, item):
</del><ins>+ def maxY(numHosts):
</ins><span class="cx"> raise NotImplementedError
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -119,14 +127,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><del>- def maxY(stats, item, host):
- return 100 * len(stats) if host is None else 100
</del><ins>+ def maxY(numHosts):
+ return 100 * numHosts
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def calculate(stats, item, hosts):
</span><del>- if hosts is None:
- hosts = stats.keys()
</del><span class="cx"> return sum([stats[onehost]["stats_system"]["cpu use"] for onehost in hosts])
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -145,14 +151,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><del>- def maxY(stats, item, host):
</del><ins>+ def maxY(numHosts):
</ins><span class="cx"> return None
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def calculate(stats, item, hosts):
</span><del>- if hosts is None:
- hosts = stats.keys()
</del><span class="cx"> return sum([stats[onehost]["stats"]["1m"]["requests"] for onehost in hosts]) / 60.0
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -171,14 +175,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><del>- def maxY(stats, item, host):
</del><ins>+ def maxY(numHosts):
</ins><span class="cx"> return None
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def calculate(stats, item, hosts):
</span><del>- if hosts is None:
- hosts = stats.keys()
</del><span class="cx"> tsum = sum([stats[onehost]["stats"]["1m"]["t"] for onehost in hosts])
</span><span class="cx"> rsum = sum([stats[onehost]["stats"]["1m"]["requests"] for onehost in hosts])
</span><span class="cx"> return safeDivision(tsum, rsum)
</span><span class="lines">@@ -200,14 +202,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><del>- def maxY(stats, item, host):
</del><ins>+ def maxY(numHosts):
</ins><span class="cx"> return None
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def calculate(stats, item, hosts):
</span><del>- if hosts is None:
- hosts = stats.keys()
</del><span class="cx"> result = 0
</span><span class="cx"> for onehost in hosts:
</span><span class="cx"> completed = sum(map(operator.itemgetter(2), stats[onehost]["job_assignments"]["workers"]))
</span><span class="lines">@@ -232,14 +232,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><del>- def maxY(stats, item, host):
</del><ins>+ def maxY(numHosts):
</ins><span class="cx"> return None
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def calculate(stats, item, hosts):
</span><del>- if hosts is None:
- hosts = stats.keys()
</del><span class="cx"> return sum([stats[onehost]["stats"]["1m"]["method"].get(item, 0) for onehost in hosts])
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -259,14 +257,12 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><del>- def maxY(stats, item, host):
</del><ins>+ def maxY(numHosts):
</ins><span class="cx"> return None
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def calculate(stats, item, hosts):
</span><del>- if hosts is None:
- hosts = stats.keys()
</del><span class="cx"> tsum = sum([stats[onehost]["stats"]["1m"]["method-t"].get(item, 0) for onehost in hosts])
</span><span class="cx"> rsum = sum([stats[onehost]["stats"]["1m"]["method"].get(item, 0) for onehost in hosts])
</span><span class="cx"> return safeDivision(tsum, rsum)
</span><span class="lines">@@ -287,12 +283,13 @@
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><del>- def maxY(stats, item, host):
</del><ins>+ def maxY(numHosts):
</ins><span class="cx"> return None
</span><span class="cx">
</span><span class="cx">
</span><span class="cx"> @staticmethod
</span><span class="cx"> def calculate(stats, item, hosts):
</span><ins>+ # Job queue stat only read for first host
</ins><span class="cx"> onehost = sorted(stats.keys())[0]
</span><span class="cx">
</span><span class="cx"> if item:
</span><span class="lines">@@ -370,12 +367,6 @@
</span><span class="cx"> @type hosts: L{list} or L{str}
</span><span class="cx"> """
</span><span class="cx">
</span><del>- # Initialize the plot arrays
- for measurement in valuekeys:
- y[measurement] = []
- titles[measurement] = DataType.getTitle(measurement)
- ymaxes[measurement] = None
-
</del><span class="cx"> # For each log file line, process the data for each required measurement
</span><span class="cx"> with logfile:
</span><span class="cx"> line = logfile.readline()
</span><span class="lines">@@ -388,11 +379,23 @@
</span><span class="cx">
</span><span class="cx"> if line[0] == "\x1e":
</span><span class="cx"> line = line[1:]
</span><ins>+ if line[0] != "{":
+ line = decompress(line.decode("base64"))
</ins><span class="cx"> jline = json.loads(line)
</span><span class="cx">
</span><span class="cx"> x.append(ctr)
</span><span class="cx"> ctr += 1
</span><span class="cx">
</span><ins>+ # Initialize the plot arrays when we know how many hosts there are
+ if len(y) == 0:
+ if hosts is None:
+ hosts = sorted(jline["pods"][args.p].keys())
+ for measurement in valuekeys:
+ y[measurement] = []
+ titles[measurement] = DataType.getTitle(measurement)
+ ymaxes[measurement] = DataType.getMaxY(measurement, len(hosts))
+
+
</ins><span class="cx"> for measurement in valuekeys:
</span><span class="cx"> stats = jline["pods"][args.p]
</span><span class="cx"> y[measurement].append(DataType.process(measurement, stats, hosts))
</span><span class="lines">@@ -431,6 +434,8 @@
</span><span class="cx">
</span><span class="cx"> if line[0] == "\x1e":
</span><span class="cx"> line = line[1:]
</span><ins>+ if line[0] != "{":
+ line = decompress(line.decode("base64"))
</ins><span class="cx"> jline = json.loads(line)
</span><span class="cx">
</span><span class="cx"> x.append(ctr)
</span><span class="lines">@@ -445,12 +450,12 @@
</span><span class="cx"> ykey = "{}={}".format(measurement, host)
</span><span class="cx"> y[ykey] = []
</span><span class="cx"> titles[ykey] = DataType.getTitle(measurement)
</span><del>- ymaxes[ykey] = None
</del><ins>+ ymaxes[ykey] = DataType.getMaxY(measurement, 1)
</ins><span class="cx">
</span><span class="cx"> for measurement in combinedkeys:
</span><span class="cx"> y[measurement] = []
</span><span class="cx"> titles[measurement] = DataType.getTitle(measurement)
</span><del>- ymaxes[measurement] = None
</del><ins>+ ymaxes[measurement] = DataType.getMaxY(measurement, len(hosts))
</ins><span class="cx">
</span><span class="cx"> # Get actual measurement data
</span><span class="cx"> for host in hosts:
</span><span class="lines">@@ -467,19 +472,29 @@
</span><span class="cx"> if ctr > line_start + line_count:
</span><span class="cx"> break
</span><span class="cx">
</span><del>- # Offset data that is averaged over the previous minute
</del><ins>+ # Offset data that is averaged over the previous minute. Also determine
+ # the highest max value of all the per-host measurements and scale each
+ # per-host plot to the same range.
+ overall_ymax = 0
</ins><span class="cx"> for host in hosts:
</span><span class="cx"> for measurement in perhostkeys:
</span><ins>+ ykey = "{}={}".format(measurement, host)
+ overall_ymax = max(overall_ymax, max(y[ykey]))
</ins><span class="cx"> if DataType.skip(measurement):
</span><del>- ykey = "{}={}".format(measurement, host)
</del><span class="cx"> y[ykey] = y[ykey][60:]
</span><span class="cx"> y[ykey].extend([None] * 60)
</span><ins>+ for host in hosts:
+ for measurement in perhostkeys:
+ ykey = "{}={}".format(measurement, host)
+ ymaxes[ykey] = overall_ymax
+
</ins><span class="cx"> for measurement in combinedkeys:
</span><span class="cx"> if DataType.skip(measurement):
</span><span class="cx"> y[measurement] = y[measurement][60:]
</span><span class="cx"> y[measurement].extend([None] * 60)
</span><span class="cx">
</span><span class="cx">
</span><ins>+ # Data for a single host, with jobs queued detail for all hosts
</ins><span class="cx"> # singleHost((
</span><span class="cx"> # CPUDataType.key,
</span><span class="cx"> # RequestsDataType.key,
</span><span class="lines">@@ -489,6 +504,8 @@
</span><span class="cx"> # JobQueueDataType.key + "-PUSH",
</span><span class="cx"> # JobQueueDataType.key,
</span><span class="cx"> # ))
</span><ins>+
+ # Data aggregated for all hosts - job detail
</ins><span class="cx"> # combinedHosts((
</span><span class="cx"> # CPUDataType.key,
</span><span class="cx"> # RequestsDataType.key,
</span><span class="lines">@@ -498,22 +515,39 @@
</span><span class="cx"> # JobQueueDataType.key + "-PUSH",
</span><span class="cx"> # JobQueueDataType.key,
</span><span class="cx"> # ))
</span><del>- combinedHosts((
- CPUDataType.key,
- RequestsDataType.key,
- ResponseDataType.key,
- MethodCountDataType.key + "-PUT ics",
- MethodCountDataType.key + "-REPORT cal-home-sync",
- MethodCountDataType.key + "-PROPFIND Calendar Home",
- MethodCountDataType.key + "-REPORT cal-sync",
- MethodCountDataType.key + "-PROPFIND Calendar",
- ))
</del><ins>+
+
+ # Data aggregated for all hosts - method detail
+# combinedHosts((
+# CPUDataType.key,
+# RequestsDataType.key,
+# ResponseDataType.key,
+# MethodCountDataType.key + "-PUT ics",
+# MethodCountDataType.key + "-REPORT cal-home-sync",
+# MethodCountDataType.key + "-PROPFIND Calendar Home",
+# MethodCountDataType.key + "-REPORT cal-sync",
+# MethodCountDataType.key + "-PROPFIND Calendar",
+# ))
+
+ # Per-host CPU, and total CPU
</ins><span class="cx"> # perHost((
</span><span class="cx"> # RequestsDataType.key,
</span><span class="cx"> # ), (
</span><span class="cx"> # CPUDataType.key,
</span><ins>+# ))
+
+ # Per-host job completion, and total CPU, total jobs queued
+# singleHost((
+# CPUDataType.key,
+# JobsCompletedDataType.key,
</ins><span class="cx"> # JobQueueDataType.key,
</span><span class="cx"> # ))
</span><ins>+ perHost((
+ JobsCompletedDataType.key,
+ ), (
+ CPUDataType.key,
+ JobQueueDataType.key,
+ ))
</ins><span class="cx">
</span><span class="cx"> # Generate a single stacked plot of the data
</span><span class="cx"> for plotnum, measurement in enumerate(y.keys()):
</span></span></pre>
</div>
</div>
</body>
</html>