aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuido G√ľnther <agx@sigxcpu.org>2008-10-24 13:18:02 +0200
committerGuido Guenther <agx@sigxcpu.org>2008-10-27 20:07:51 +0100
commit310af9e9dc69e46c90d95ec8bf810d521fa53079 (patch)
treed11f978c64634c27f4c50ff7580228dbfb98db37
parent725b681e1911b693ee3bbba56306e73bd43fa9ef (diff)
calculate total used cputime percentage
but don't display it - this way it can be used by munin-limits
-rw-r--r--libvirt-cputime14
1 files changed, 12 insertions, 2 deletions
diff --git a/libvirt-cputime b/libvirt-cputime
index 8758b17..86394ac 100644
--- a/libvirt-cputime
+++ b/libvirt-cputime
@@ -26,7 +26,15 @@ def print_config(uri, stack):
graph_vlabel CPU Time percentage
graph_category Virtual Machines
graph_info This graph shows the cpu time percentage of each virtual machine
-graph_args --base 1000 -l 0"""
+graph_args --base 1000 -l 0
+total_pc.type DERIVE
+total_pc.graph no
+total_pc.min 0
+total_pc.max 100
+total_pc.label total
+total_pc.info cputime used by all virtual machines
+total_pc.warning 90
+total_pc.critical 95"""
draw = [ "LINE1", "AREA"][stack]
conn = libvirt.openReadOnly(uri)
@@ -41,10 +49,10 @@ graph_args --base 1000 -l 0"""
if draw == "AREA":
draw = "STACK"
-
def fetch_values(uri):
conn = libvirt.openReadOnly(uri)
ids = conn.listDomainsID()
+ total = 0
processors = float(conn.getInfo()[2])
for id in ids:
@@ -52,7 +60,9 @@ def fetch_values(uri):
name = dom.name()
cputime = float(dom.info()[4])
cputime_percentage = 1.0e-7 * cputime / processors
+ total += cputime_percentage
print "%s_cputime.value %.0f" % (canon(name), cputime_percentage)
+ print "total_pc.value %.0f" % total
def main(sys):