Hi all,
 I wrote a small python-script to monitor the status of the started VMs 
based on the xenmon.py and the following code I got from Anthony Liguori:
----------------------------------------
import sys
sys.path.append('/usr/lib/python')
sys.path.append('/usr/lib64/python')
from xen.xend.XendClient import server
from xen.xend import sxp
def parse_doms_info(info):
    def get_info(n, t, d):
        return t(sxp.child_value(info, n, d))
    return {
        'dom'      : get_info('domid',        int,   -1),
        'name'     : get_info('name',         str,   '??'),
        'mem'      : get_info('memory',       int,   0),
        'vcpus'    : get_info('online_vcpus', int,   0),
        'state'    : get_info('state',        str,   '??'),
        'cpu_time' : get_info('cpu_time',     float, 0),
        'ssidref'  : get_info('ssidref',      int,   0),
        }
doms = server.xend_list_domains()
print 'Name                              ID Mem(MiB) VCPUs State  Time(s)'
for dom in doms:
    d = parse_doms_info(dom)
    if (d['ssidref'] != 0):
        d['ssidstr'] = (" s:%04x/p:%04x" %
                        ((d['ssidref'] >> 16) & 0xffff,
                          d['ssidref']        & 0xffff))
    else:
        d['ssidstr'] = ""
    print ("%(name)-32s %(dom)3d %(mem)8d %(vcpus)5d %(state)5s% 
(cpu_time)7.1f% (ssidstr)s" % d)
----------------------------------------
 I wrote the script on SUSE SLES 10.0 Beta 3 with Xen 3.0_8659-2. 
Unfortunately this script (and therefor my one too) ist not running 
anymore with the latest SUSE SLES 10.0 Beta 9 that includes Xen 
3.0.2_09434-2 :-(
 It breaks at line "doms = server.xend_list_domains()" with the following 
error:
----------------------------------------
Traceback (most recent call last):
  File "xentest1.py", line 22, in ?
    doms = server.xend_list_domains()
  File "/usr/lib/python2.4/xmlrpclib.py", line 1096, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.4/xmlrpclib.py", line 1383, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.4/site-packages/xen/util/xmlrpclib2.py", line 
46, in request
    return Transport.request(self, host, '/RPC2', request_body, verbose)
  File "/usr/lib/python2.4/xmlrpclib.py", line 1147, in request
    return self._parse_response(h.getfile(), sock)
  File "/usr/lib/python2.4/xmlrpclib.py", line 1286, in _parse_response
    return u.close()
  File "/usr/lib/python2.4/xmlrpclib.py", line 744, in close
    raise Fault(**self._stack[0])
xmlrpclib.Fault: <Fault 1: 'Traceback (most recent call last):\n  File 
"/usr/lib/python2.4/site-packages/xen/util/xmlrpclib2.py", line 74, in 
_marshaled_dispatch\n    response = self._dispatch(method, params)\n 
File "/usr/lib/python2.4/SimpleXMLRPCServer.py", line 408, in 
_dispatch\n    raise Exception(\'method "%s" is not supported\' % 
method)\nException: method "xend_list_domains" is not supported\n'>
----------------------------------------
 If I see right it now uses "/usr/lib/python2.4/SimpleXMLRPCServer.py" 
(what does not exist in Xen 3.0_8659-2) and breaks because the method 
"xend_list_domains" is not supported anymore I use to get the 
domain-informations with the script.
 Is there a better way to get the VM-status like name, memory, state, 
CPU-usage etc. via Python than using the mechanism from xenmon.py and 
the above one?
Thanks a lot for your answers,
--
Chau y hasta luego,
Thorolf
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
 
 |