Nir Soffer has uploaded a new change for review.

Change subject: repoplot: Visualize storage domain monitoring
......................................................................

repoplot: Visualize storage domain monitoring

Add repoplot command line tool for visualizing storage domain monitoring
issues.

Usage:

    repostat vdsm.log ...

The tool extracts lastCheck and delay values for all storage domains,
and plot a graph that can be saved in various formats.

Requires the python-pandas package.

Change-Id: Ic0366d45b1fb59aab75843bff4224c8b572dd265
Bug-Url: https://bugzilla.redhat.com/1081962
Signed-off-by: Nir Soffer <[email protected]>
---
A contrib/repoplot
1 file changed, 135 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/61/53861/1

diff --git a/contrib/repoplot b/contrib/repoplot
new file mode 100755
index 0000000..4e52391
--- /dev/null
+++ b/contrib/repoplot
@@ -0,0 +1,135 @@
+#!/usr/bin/python
+#
+# Copyright 2014 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+#
+# Refer to the README and COPYING files for full details of the license
+#
+
+"""
+Parse repoStats log lines and plot graphs of lastCheck and read delay for all
+storage domains.
+
+Usage: repoplot vdsm.log [...]
+
+Requirements: python-pandas
+"""
+
+import fileinput
+import re
+import sys
+from collections import defaultdict
+
+import pandas
+from matplotlib import pyplot
+
+PREFIX = re.compile(r"^.+?::.+?::(.+?)::.+Run and protect: repoStats, "
+                    "Return response: ")
+
+
+def main(args):
+    stats = parse()
+    lastcheck = dataframe(stats, "lastcheck")
+    delay = dataframe(stats, "delay")
+    plot(lastcheck, delay)
+
+
+class DomainStats(object):
+    def __init__(self):
+        self.timestamp = []
+        self.lastcheck = []
+        self.delay = []
+
+
+def parse():
+    """
+    Parse repoStat from vdsm log. Return dict of DomainStats objects.
+    """
+    stats = defaultdict(DomainStats)
+
+    for line in fileinput.input():
+        match = PREFIX.search(line)
+        if not match:
+            continue
+        timestamp = match.group(1)
+        timestamp, millis = timestamp.split(",", 1)
+        timestamp = pandas.Timestamp(timestamp)
+        response = eval(line[match.end():])
+        for uuid, info in response.items():
+            ds = stats[uuid]
+            ds.timestamp.append(timestamp)
+            ds.lastcheck.append(float(info["lastCheck"]))
+            ds.delay.append(float(info["delay"]))
+
+    return stats
+
+
+def dataframe(stats, key):
+    """
+    Create pandas.DataFrame with one column per domain for given key.
+    """
+    dfs = []
+
+    for uuid, ds in stats.iteritems():
+        df = pandas.DataFrame(getattr(ds, key), index=ds.timestamp,
+                              columns=[uuid])
+        dfs.append(df)
+
+    combined = pandas.concat(dfs, axis=1)
+
+    return combined
+
+
+def plot(lastcheck, delay):
+    pyplot.subplot(211)
+    pyplot.title("lastCheck")
+    pyplot.ylabel("lastCheck (seconds)")
+    pyplot.xlabel("time")
+    pyplot.grid(True)
+
+    pyplot.plot(lastcheck.index, lastcheck)
+
+    threshold = pandas.Series([30] * len(lastcheck),
+                              index=lastcheck.index)
+    pyplot.plot(threshold.index, threshold, color="gray",
+                linewidth="2")
+
+    # Show values up to 330 seconds. Bigger values will cause a host to become
+    # non-operational.
+    pyplot.axis([lastcheck.index[0], lastcheck.index[-1], 0, 330])
+
+    pyplot.subplot(212)
+    pyplot.title("read delay")
+    pyplot.ylabel("delay (seconds)")
+    pyplot.xlabel("time")
+    pyplot.grid(True)
+
+    pyplot.plot(delay.index, delay)
+
+    threshold = pandas.Series([5] * len(lastcheck),
+                              index=lastcheck.index)
+    pyplot.plot(threshold.index, threshold, color="gray",
+                linewidth="2")
+
+    # Show values up to 10 seconds. Values bigger then 5 seconds will show a
+    # warning in engine log.
+    pyplot.axis([lastcheck.index[0], lastcheck.index[-1], 0, 10])
+
+    pyplot.show()
+
+
+if __name__ == "__main__":
+    main(sys.argv)


-- 
To view, visit https://gerrit.ovirt.org/53861
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic0366d45b1fb59aab75843bff4224c8b572dd265
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Nir Soffer <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to