Bumped number for precise
[invirt/packages/xvm-munin-config.git] / host / usr / share / xvm-munin-host-config / plugins / xen_cpu
index 755c476..06850cf 100755 (executable)
@@ -3,9 +3,14 @@
 from xen.xm.main import SERVER_LEGACY_XMLRPC, SERVER_XEN_API, parseServer, parseAuthentication
 from xen.xend import sxp
 import atexit
+import sys
 
 serverType, serverURI = parseServer()
 
+if serverType != SERVER_LEGACY_XMLRPC:
+    print >>sys.stderr, "xen_cpu is untested with this Xen server type"
+    sys.exit(1)
+
 if serverType == SERVER_XEN_API:
     from xen.xm import XenAPI
     server = XenAPI.Session(serverURI)
@@ -21,8 +26,6 @@ else:
     from xen.util.xmlrpcclient import ServerProxy
     server = ServerProxy(serverURI)
 
-import sys
-
 if len(sys.argv) > 1:
     cmd = sys.argv[1]
 else:
@@ -34,12 +37,12 @@ def getDomains():
         domains = server.xenapi.VM.get_all_records()
         metrics = server.xenapi.VM_metrics.get_all_records()
         for d in domains.values():
-            ret[d['uuid'].replace('-', '_')] = {'name': d['name_label'],
-                                                'cpu_time': sum(metrics[d['metrics']]['VCPUs_utilisation'].values()),
-                                                'domid': d['domid'],
-                                                'uuid': d['uuid'],
-                                                # No equivalent
-                                                }
+            ret['uuid_'+d['uuid'].replace('-', '_')] = {'name': d['name_label'],
+                                                        'cpu_time': sum(metrics[d['metrics']]['VCPUs_utilisation'].values()),
+                                                        'domid': d['domid'],
+                                                        'uuid': d['uuid'],
+                                                        # No equivalent
+                                                        }
         return ret
     else:
         domains = server.xend.domains_with_state(True, 'all', True)
@@ -54,7 +57,7 @@ def getDomains():
                 data['sched-credit'] = sched
             except:
                 data['sched-credit'] = None
-            ret[sxp.child_value(d, 'uuid', 'NONE').replace('-', '_')] = data
+            ret['uuid_'+sxp.child_value(d, 'uuid', 'NONE').replace('-', '_')] = data
         return ret
 
 if cmd == 'config':