Ignore:
Timestamp:
May 15, 2008, 8:58:19 PM (17 years ago)
Author:
quentin
Message:

Compute uptime on the server so time drift doesn't cause problems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/sipb-xen-remctl-auto/files/usr/sbin/sipb-xen-listvms

    r531 r533  
    22
    33import sys
     4import time
    45sys.path.insert(0, '/usr/lib/xen-3.1-1/lib/python')
    56from xen.lowlevel.xs import xs
     
    910def live_vms():
    1011    domids = set(trans.ls('', '/local/domain'))
    11     domids.remove('0')
     12    domids.discard('0')
    1213
    1314    vms = dict()
     
    2930    data['vm'] = trans.read('', '/local/domain/%d/vm' % domid)
    3031    data['start_time'] = float(trans.read('', '%s/start_time' % data['vm']))
     32    data['uptime'] = time.time()-data['start_time']
    3133   
    3234    return name, data
     
    3638    if '--pickle' in sys.argv[1:]:
    3739        import cPickle
    38         cPickle.dump(vms, sys.stdout)
     40        cPickle.dump(vms, sys.stdout, cPickle.HIGHEST_PROTOCOL)
    3941    else:
    4042        print vms
Note: See TracChangeset for help on using the changeset viewer.