From 74df0b58b5f04569df06bd10baecaec4e8751eb6 Mon Sep 17 00:00:00 2001
From: Brian Warner <warner@allmydata.com>
Date: Wed, 7 May 2008 13:19:08 -0700
Subject: [PATCH] munin: add tahoe_cpu_watcher.py, to track the data from
 misc/cpu-watcher.tac

---
 misc/munin/tahoe_cpu_watcher.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100644 misc/munin/tahoe_cpu_watcher.py

diff --git a/misc/munin/tahoe_cpu_watcher.py b/misc/munin/tahoe_cpu_watcher.py
new file mode 100644
index 00000000..1b1df335
--- /dev/null
+++ b/misc/munin/tahoe_cpu_watcher.py
@@ -0,0 +1,29 @@
+#! /usr/bin/python
+
+import os, sys, re
+import urllib
+import simplejson
+
+url = os.environ["url"]
+current = simplejson.loads(urllib.urlopen(url).read())
+
+configinfo = """\
+graph_title Tahoe CPU Usage
+graph_vlabel CPU %
+graph_category tahoe
+graph_info This graph shows the 5min average of CPU usage for each process
+"""
+data = ""
+
+for (name, avg1, avg5, avg15) in current:
+    dataname = re.sub(r'[^\w]', '_', name)
+    configinfo += dataname + ".label " + name + "\n"
+    configinfo += dataname + ".draw LINE2\n"
+    if avg5 is not None:
+        data += dataname + ".value %.2f\n" % (100.0 * avg5)
+
+if len(sys.argv) > 1:
+    if sys.argv[1] == "config":
+        print configinfo.rstrip()
+        sys.exit(0)
+print data.rstrip()
-- 
2.45.2