VirtualBox

忽略:
時間撮記:
2008-9-12 上午07:08:22 (16 年 以前)
作者:
vboxsync
訊息:

fixed guest stats

檔案:
修改 1 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/libs/xpcom18a4/python/sample/shellcommon.py

    r12403 r12411  
    8686    rc = progress.resultCode
    8787    print "Completed:", completed, "rc:",rc
     88    if rc == 0:
     89        vb.performanceCollector.setupMetrics(['*'], [mach], 10, 15)
    8890    session.close()
    8991
     
    9799        return 'off'
    98100
    99 def guestStats2(ctx,guest):
    100     stats = {
    101         'Guest statistics for sample': ctx['ifaces'].GuestStatisticType.SampleNumber,
    102         'CPU Load Idle': ctx['ifaces'].GuestStatisticType.CPULoad_Idle,
    103         'CPU Load User': ctx['ifaces'].GuestStatisticType.CPULoad_User,
    104         'CPU Load Kernel': ctx['ifaces'].GuestStatisticType.CPULoad_Kernel,
    105         'Threads': ctx['ifaces'].GuestStatisticType.Threads,
    106         'Processes': ctx['ifaces'].GuestStatisticType.Processes,
    107         'Handles': ctx['ifaces'].GuestStatisticType.Handles,
    108         }
    109     for (k,v) in stats.items():
    110         try:
    111             val = guest.getStatistic(0, v)
    112             print "'%s' = '%s'" %(k,str(v))
    113         except:
    114             print "Cannot get value for '%s'"  %(k)
    115             pass
    116 
    117101def guestStats(ctx,mach):
    118102    collector = ctx['vb'].performanceCollector
    119     collector.setupMetrics(['*'], [mach], 1, 15)
    120 
    121103    (vals, names, objs, idxs, lens) = collector.queryMetricsData(["*"], [mach])
    122104    for i in range(0,len(names)):
    123         valsStr = '['
     105        valsStr = '[ '
    124106        for j in range(0, lens[i]):
    125107            valsStr += str(vals[idxs[i]])+' '
    126108        valsStr += ']'
    127         print "Name:",names[i],"Vals:",valsStr
     109        print names[i],valsStr
    128110
    129111def cmdExistingVm(ctx,mach,cmd):
     
    143125        return
    144126    # unfortunately IGuest is suppressed, thus WebServices knows not about it
     127    # this is an example how to handle local only functionality
    145128    if ctx['remote'] and cmd == 'stats2':
    146129        print 'Trying to use local only functionality, ignored'
     
    150133         'resume':     lambda: console.resume(),
    151134         'powerdown':  lambda: console.powerDown(),
    152 # Guest stats not yet implemented
    153 #         'stats2':      lambda: guestStats2(ctx, console.guest),
    154 #         'stats':      lambda: guestStats(ctx, mach),
     135         'stats':      lambda: guestStats(ctx, mach),
    155136         }
    156137    ops[cmd]()
     
    311292   (vals, names, objs, idxs, lens) = collector.queryMetricsData(["*"], [host])
    312293   for i in range(0,len(names)):
    313        valsStr = '['
     294       valsStr = '[ '
    314295       for j in range(0, lens[i]):
    315296           valsStr += str(vals[idxs[i]])+' '
    316297       valsStr += ']'
    317        print "Name:",names[i],"Vals:",valsStr
     298       print names[i],valsStr
    318299
    319300   return 0
     
    331312            'pause':['Pause virtual machine', pauseCmd],
    332313            'resume':['Resume virtual machine', resumeCmd],
    333 # stats not yet well implemented
    334314            'stats':['Stats for virtual machine', statsCmd],
    335315            'powerdown':['Power down virtual machine', powerdownCmd],
     
    361341    autoCompletion(commands, ctx)
    362342
    363     # to allow to print actual host information, we collect infor for
     343    # to allow to print actual host information, we collect info for
    364344    # last 150 secs maximum, (sample every 10 secs and keep up to 15 samples)
    365345    vbox.performanceCollector.setupMetrics(['*'], [vbox.host], 10, 15)
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette