From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorolf Godawa Subject: Error getting VM-informations with Python on Xen 3.0.2 Date: Wed, 05 Apr 2006 21:24:09 +0200 Message-ID: <44341959.5030708@Godawa.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org 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: ---------------------------------------- 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