- Timestamp:
- Sep 12, 2008 7:08:22 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/python/sample/shellcommon.py
r12403 r12411 86 86 rc = progress.resultCode 87 87 print "Completed:", completed, "rc:",rc 88 if rc == 0: 89 vb.performanceCollector.setupMetrics(['*'], [mach], 10, 15) 88 90 session.close() 89 91 … … 97 99 return 'off' 98 100 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 pass116 117 101 def guestStats(ctx,mach): 118 102 collector = ctx['vb'].performanceCollector 119 collector.setupMetrics(['*'], [mach], 1, 15)120 121 103 (vals, names, objs, idxs, lens) = collector.queryMetricsData(["*"], [mach]) 122 104 for i in range(0,len(names)): 123 valsStr = '[ '105 valsStr = '[ ' 124 106 for j in range(0, lens[i]): 125 107 valsStr += str(vals[idxs[i]])+' ' 126 108 valsStr += ']' 127 print "Name:",names[i],"Vals:",valsStr109 print names[i],valsStr 128 110 129 111 def cmdExistingVm(ctx,mach,cmd): … … 143 125 return 144 126 # unfortunately IGuest is suppressed, thus WebServices knows not about it 127 # this is an example how to handle local only functionality 145 128 if ctx['remote'] and cmd == 'stats2': 146 129 print 'Trying to use local only functionality, ignored' … … 150 133 'resume': lambda: console.resume(), 151 134 '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), 155 136 } 156 137 ops[cmd]() … … 311 292 (vals, names, objs, idxs, lens) = collector.queryMetricsData(["*"], [host]) 312 293 for i in range(0,len(names)): 313 valsStr = '[ '294 valsStr = '[ ' 314 295 for j in range(0, lens[i]): 315 296 valsStr += str(vals[idxs[i]])+' ' 316 297 valsStr += ']' 317 print "Name:",names[i],"Vals:",valsStr298 print names[i],valsStr 318 299 319 300 return 0 … … 331 312 'pause':['Pause virtual machine', pauseCmd], 332 313 'resume':['Resume virtual machine', resumeCmd], 333 # stats not yet well implemented334 314 'stats':['Stats for virtual machine', statsCmd], 335 315 'powerdown':['Power down virtual machine', powerdownCmd], … … 361 341 autoCompletion(commands, ctx) 362 342 363 # to allow to print actual host information, we collect info rfor343 # to allow to print actual host information, we collect info for 364 344 # last 150 secs maximum, (sample every 10 secs and keep up to 15 samples) 365 345 vbox.performanceCollector.setupMetrics(['*'], [vbox.host], 10, 15)
Note:
See TracChangeset
for help on using the changeset viewer.