5 sys.path.insert(0, '/usr/lib/xen-3.1-1/lib/python')
6 from xen.xend.xenstore import xstransact
8 xst = xstransact.xstransact()
11 domids = set(xst.List('/local/domain'))
18 name, data = get_dom(int(domid))
20 continue # went down since we started
21 if name.startswith('d_'):
27 name = xst.Read('/local/domain/%d/name' % domid)
30 # presence of a graphical console
31 data['console'] = xst.Read('/local/domain/%d/device/vfb/0/state' % domid)
33 data['vm'] = xst.Read('/local/domain/%d/vm' % domid)
34 data['start_time'] = float(xst.Read('%s/start_time' % data['vm']))
35 data['uptime'] = time.time()-data['start_time']
39 if __name__ == '__main__':
41 if '--json' in sys.argv[1:]:
43 print cjson.encode(vms)
44 elif '--pickle' in sys.argv[1:]:
46 cPickle.dump(vms, sys.stdout, cPickle.HIGHEST_PROTOCOL)
49 print yaml.dump(vms, Dumper=yaml.CSafeDumper, default_flow_style=False)