All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thorolf Godawa <Thorolf@Godawa.de>
To: xen-devel@lists.xensource.com
Subject: Error getting VM-informations with Python on Xen 3.0.2
Date: Wed, 05 Apr 2006 21:24:09 +0200	[thread overview]
Message-ID: <44341959.5030708@Godawa.de> (raw)

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

             reply	other threads:[~2006-04-05 19:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-05 19:24 Thorolf Godawa [this message]
  -- strict thread matches above, loose matches on Subject: below --
2006-04-05 19:24 Error getting VM-informations with Python on Xen 3.0.2 Thorolf Godawa
2006-04-06  0:27 ` Ewan Mellor
2006-04-06  9:02   ` Thorolf Godawa
2006-04-06 13:05     ` Ewan Mellor
2006-04-06 13:06       ` Ewan Mellor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44341959.5030708@Godawa.de \
    --to=thorolf@godawa.de \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.