Index: trunk/packages/xvm-munin-config/debian/changelog
===================================================================
--- trunk/packages/xvm-munin-config/debian/changelog	(revision 1777)
+++ trunk/packages/xvm-munin-config/debian/changelog	(revision 1779)
@@ -1,2 +1,10 @@
+xvm-munin-config (0.0.5) unstable; urgency=low
+
+  * Fix typos in xen_cpu script for XenAPI code
+  * Bump theoretical CPU max to 64x
+  * Show domain CPU weight and cap if available
+
+ -- Quentin Smith <quentin@mit.edu>  Tue, 25 Nov 2008 22:46:12 -0500
+
 xvm-munin-config (0.0.4) unstable; urgency=low
 
Index: trunk/packages/xvm-munin-config/host/usr/share/xvm-munin-host-config/plugins/xen_cpu
===================================================================
--- trunk/packages/xvm-munin-config/host/usr/share/xvm-munin-host-config/plugins/xen_cpu	(revision 1777)
+++ trunk/packages/xvm-munin-config/host/usr/share/xvm-munin-host-config/plugins/xen_cpu	(revision 1779)
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
-from xen.xm.main import SERVER_LEGACY_XMLRPC, SERVER_XEN_API, parseServer
+from xen.xm.main import SERVER_LEGACY_XMLRPC, SERVER_XEN_API, parseServer, parseAuthentication
 from xen.xend import sxp
+import atexit
 
 serverType, serverURI = parseServer()
@@ -31,5 +32,5 @@
     ret = {}
     if serverType == SERVER_XEN_API:
-        domains = server.xenapu.VM.get_all_records()
+        domains = server.xenapi.VM.get_all_records()
         metrics = server.xenapi.VM_metrics.get_all_records()
         for d in domains.values():
@@ -38,4 +39,5 @@
                                                 'domid': d['domid'],
                                                 'uuid': d['uuid'],
+                                                # No equivalent
                                                 }
         return ret
@@ -43,9 +45,15 @@
         domains = server.xend.domains_with_state(True, 'all', True)
         for d in domains:
-            ret[sxp.child_value(d, 'uuid', 'NONE').replace('-', '_')] = {'name': sxp.child_value(d, 'name', 'UNKNOWN'),
-                                                                         'cpu_time': sxp.child_value(d, 'cpu_time', 0.0),
-                                                                         'domid': sxp.child_value(d, 'domid', -1),
-                                                                         'uuid': sxp.child_value(d, 'uuid', 'NONE'),
-                                                                         }
+            data = {'name': sxp.child_value(d, 'name', 'UNKNOWN'),
+                    'cpu_time': sxp.child_value(d, 'cpu_time', 0.0),
+                    'domid': sxp.child_value(d, 'domid', -1),
+                    'uuid': sxp.child_value(d, 'uuid', 'NONE'),
+                    }
+            try:
+                sched = server.xend.domain.sched_credit_get(data['name'])
+                data['sched-credit'] = sched
+            except:
+                data['sched-credit'] = None
+            ret[sxp.child_value(d, 'uuid', 'NONE').replace('-', '_')] = data
         return ret
 
@@ -63,5 +71,5 @@
         name = domains[d]['name']
         if name[0:2] == 'd_':
-            name = 'user domain'
+            name = 'db domid %d' % domains[d]['domid']
         print "%s.label %s" % (d, name)
         if domains[d]['domid'] == 0:
@@ -69,8 +77,11 @@
         else:
             print "%s.draw STACK" % d
-        print "%s.max 5000" % d
+        print "%s.max 19200000000" % d # 64x 100% CPU usage
         print "%s.min 0" % d
         print "%s.type DERIVE" % d
-        print "%s.info %s" % (d, domains[d]['uuid'])
+        if domains[d].get('sched-credit'):
+            print "%s.info uuid %s CPU weight %d cap %d%%" % (d, domains[d]['uuid'], domains[d]['sched-credit']['weight'], domains[d]['sched-credit']['cap'])
+        else:
+            print "%s.info uuid %s" % (d, domains[d]['uuid'])
         print "%s.cdef %s,10000,/" % (d, d)
     sys.exit(0)
