- Timestamp:
- Mar 31, 2010 7:33:59 AM (15 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/MachineImpl.cpp
r27835 r27849 8952 8952 8953 8953 /* Create and register base metrics */ 8954 pm::BaseMetric *guestCpuLoad = new pm::GuestCpuLoad( hal, aMachine, guestLoadUser, guestLoadKernel, guestLoadIdle);8954 pm::BaseMetric *guestCpuLoad = new pm::GuestCpuLoad(&mGuestHAL, aMachine, guestLoadUser, guestLoadKernel, guestLoadIdle); 8955 8955 aCollector->registerBaseMetric(guestCpuLoad); 8956 8956 8957 pm::BaseMetric *guestCpuMem = new pm::GuestRamUsage( hal, aMachine, guestMemTotal, guestMemFree, guestMemBalloon,8957 pm::BaseMetric *guestCpuMem = new pm::GuestRamUsage(&mGuestHAL, aMachine, guestMemTotal, guestMemFree, guestMemBalloon, 8958 8958 guestMemCache, guestPagedTotal, guestPagedFree); 8959 8959 aCollector->registerBaseMetric(guestCpuMem); 8960 8960 8961 pm::BaseMetric *guestSystem = new pm::GuestSystemUsage( hal, aMachine, guestSystemProc, guestSystemThread);8961 pm::BaseMetric *guestSystem = new pm::GuestSystemUsage(&mGuestHAL, aMachine, guestSystemProc, guestSystemThread); 8962 8962 aCollector->registerBaseMetric(guestSystem); 8963 8963 -
trunk/src/VBox/Main/Performance.cpp
r27822 r27849 66 66 } 67 67 68 int CollectorHAL::getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available) 69 { 70 return E_NOTIMPL; 71 } 72 73 int CollectorHAL::getProcessMemoryUsage(RTPROCESS process, ULONG *used) 74 { 75 return E_NOTIMPL; 76 } 77 78 int CollectorHAL::enable() 79 { 80 return E_NOTIMPL; 81 } 82 83 int CollectorHAL::disable() 84 { 85 return E_NOTIMPL; 86 } 87 68 88 /* Generic implementations */ 69 89 … … 97 117 98 118 return VINF_SUCCESS; 119 } 120 121 CollectorGuestHAL::~CollectorGuestHAL() 122 { 123 // if (cEnabled) 124 // 125 } 126 127 int CollectorGuestHAL::enable() 128 { 129 return S_OK; 130 } 131 132 int CollectorGuestHAL::disable() 133 { 134 return S_OK; 99 135 } 100 136 -
trunk/src/VBox/Main/include/MachineImpl.h
r27835 r27849 37 37 #include "VBox/settings.h" 38 38 #ifdef VBOX_WITH_RESOURCE_USAGE_API 39 #include "Performance.h" 39 40 #include "PerformanceImpl.h" 40 41 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ … … 794 795 void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid); 795 796 void unregisterMetrics(PerformanceCollector *aCollector, Machine *aMachine); 797 798 pm::CollectorGuestHAL mGuestHAL; 796 799 #endif /* VBOX_WITH_RESOURCE_USAGE_API */ 797 800 -
trunk/src/VBox/Main/include/Performance.h
r27822 r27849 21 21 * additional information or have any questions. 22 22 */ 23 23 #ifndef ___performance_h 24 #define ___performance_h 24 25 25 26 #include <VBox/com/defs.h> … … 74 75 /* Collector Hardware Abstraction Layer *********************************/ 75 76 enum { 76 COLLECT_NONE = 0x0,77 COLLECT_CPU_LOAD = 0x1,78 COLLECT_RAM_USAGE = 0x277 COLLECT_NONE = 0x0, 78 COLLECT_CPU_LOAD = 0x1, 79 COLLECT_RAM_USAGE = 0x2 79 80 }; 80 81 typedef int HintFlags; … … 141 142 virtual int getHostCpuMHz(ULONG *mhz); 142 143 /** Returns the amount of physical memory in kilobytes. */ 143 virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available) = 0;144 virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available); 144 145 /** Returns CPU usage in 1/1000th per cent by a particular process. */ 145 146 virtual int getProcessCpuLoad(RTPROCESS process, ULONG *user, ULONG *kernel); 146 147 /** Returns the amount of memory used by a process in kilobytes. */ 147 virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used) = 0;148 virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used); 148 149 149 150 /** Returns CPU usage counters in platform-specific units. */ … … 151 152 /** Returns process' CPU usage counter in platform-specific units. */ 152 153 virtual int getRawProcessCpuLoad(RTPROCESS process, uint64_t *user, uint64_t *kernel, uint64_t *total); 154 155 /** Enable metrics collecting (if applicable) */ 156 virtual int enable(); 157 /** Disable metrics collecting (if applicable) */ 158 virtual int disable(); 159 }; 160 161 class CollectorGuestHAL : public CollectorHAL 162 { 163 public: 164 CollectorGuestHAL() : cEnabled(0) {}; 165 ~CollectorGuestHAL(); 166 167 /** Enable metrics collecting (if applicable) */ 168 virtual int enable(); 169 /** Disable metrics collecting (if applicable) */ 170 virtual int disable(); 171 protected: 172 unsigned cEnabled; 153 173 }; 154 174 … … 173 193 bool collectorBeat(uint64_t nowAt); 174 194 175 void enable() { mEnabled = true; }; 176 void disable() { mEnabled = false; }; 195 void enable() 196 { 197 mEnabled = true; 198 mHAL->enable(); 199 }; 200 void disable() 201 { 202 mHAL->disable(); 203 mEnabled = false; 204 }; 177 205 178 206 bool isEnabled() { return mEnabled; }; … … 322 350 { 323 351 public: 324 GuestCpuLoad(Collector HAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle)352 GuestCpuLoad(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *user, SubMetric *kernel, SubMetric *idle) 325 353 : BaseMetric(hal, "CPU/Load", object), mUser(user), mKernel(kernel), mIdle(idle) {}; 326 354 ~GuestCpuLoad() { delete mUser; delete mKernel; delete mIdle; }; … … 342 370 { 343 371 public: 344 GuestRamUsage(Collector HAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *free, SubMetric *balloon, SubMetric *cache, SubMetric *pagedtotal, SubMetric *pagedfree)372 GuestRamUsage(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *total, SubMetric *free, SubMetric *balloon, SubMetric *cache, SubMetric *pagedtotal, SubMetric *pagedfree) 345 373 : BaseMetric(hal, "RAM/Usage", object), mTotal(total), mFree(free), mBallooned(balloon), mCache(cache), mPagedTotal(pagedtotal), mPagedFree(pagedfree) {}; 346 374 ~GuestRamUsage() { delete mTotal; delete mFree; delete mBallooned; delete mCache; delete mPagedTotal; delete mPagedFree; }; … … 360 388 { 361 389 public: 362 GuestSystemUsage(Collector HAL *hal, ComPtr<IUnknown> object, SubMetric *processes, SubMetric *threads)390 GuestSystemUsage(CollectorGuestHAL *hal, ComPtr<IUnknown> object, SubMetric *processes, SubMetric *threads) 363 391 : BaseMetric(hal, "System/Usage", object), mProcesses(processes), mThreads(threads) {}; 364 392 ~GuestSystemUsage() { delete mProcesses; delete mThreads; }; … … 466 494 }; 467 495 } 468 496 #endif /* ___performance_h */ 469 497 /* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note:
See TracChangeset
for help on using the changeset viewer.