Changeset 43949 in vbox
- Timestamp:
- Nov 23, 2012 1:43:19 PM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/MachineImpl.h
r43915 r43949 944 944 945 945 #ifdef VBOX_WITH_RESOURCE_USAGE_API 946 void getDiskList(MediaList &list); 946 947 void registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid); 947 948 -
trunk/src/VBox/Main/include/Performance.h
r43933 r43949 32 32 #include <vector> 33 33 #include <queue> 34 35 #include "MediumImpl.h" 34 36 35 37 /* Forward decl. */ … … 693 695 694 696 #ifndef VBOX_COLLECTOR_TEST_CASE 697 typedef std::list<ComObjPtr<Medium> > MediaList; 698 class MachineDiskUsage : public BaseMetric 699 { 700 public: 701 MachineDiskUsage(CollectorHAL *hal, ComPtr<IUnknown> object, MediaList &disks, SubMetric *used) 702 : BaseMetric(hal, "Disk/Usage", object), mDisks(disks), mUsed(used) {}; 703 ~MachineDiskUsage() { delete mUsed; }; 704 705 void init(ULONG period, ULONG length); 706 void preCollect(CollectorHints& hints, uint64_t iTick); 707 void collect(); 708 const char *getUnit() { return "mB"; }; 709 ULONG getMinValue() { return 0; }; 710 ULONG getMaxValue() { return INT32_MAX; }; 711 ULONG getScale() { return 1; } 712 private: 713 MediaList mDisks; 714 SubMetric *mUsed; 715 }; 716 695 717 /* 696 718 * Although MachineNetRate is measured for VM, not for the guest, it is -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r43915 r43949 11461 11461 #ifdef VBOX_WITH_RESOURCE_USAGE_API 11462 11462 11463 void Machine::getDiskList(MediaList &list) 11464 { 11465 for (MediaData::AttachmentList::const_iterator it = mMediaData->mAttachments.begin(); 11466 it != mMediaData->mAttachments.end(); 11467 ++it) 11468 { 11469 MediumAttachment* pAttach = *it; 11470 /* just in case */ 11471 AssertStmt(pAttach, continue); 11472 11473 AutoCaller localAutoCallerA(pAttach); 11474 if (FAILED(localAutoCallerA.rc())) continue; 11475 11476 AutoReadLock local_alockA(pAttach COMMA_LOCKVAL_SRC_POS); 11477 11478 if (pAttach->getType() == DeviceType_HardDisk) 11479 list.push_back(pAttach->getMedium()); 11480 } 11481 } 11482 11463 11483 void Machine::registerMetrics(PerformanceCollector *aCollector, Machine *aMachine, RTPROCESS pid) 11464 11484 { … … 11474 11494 pm::SubMetric *ramUsageUsed = new pm::SubMetric("RAM/Usage/Used", 11475 11495 "Size of resident portion of VM process in memory."); 11496 pm::SubMetric *diskUsageUsed = new pm::SubMetric("Disk/Usage/Used", 11497 "Actual size of all VM disks combined."); 11476 11498 pm::SubMetric *machineNetRx = new pm::SubMetric("Net/Rate/Rx", 11477 11499 "Network receive rate."); … … 11485 11507 ramUsageUsed); 11486 11508 aCollector->registerBaseMetric(ramUsage); 11509 MediaList disks; 11510 getDiskList(disks); 11511 pm::BaseMetric *diskUsage = new pm::MachineDiskUsage(hal, aMachine, disks, 11512 diskUsageUsed); 11513 aCollector->registerBaseMetric(diskUsage); 11487 11514 11488 11515 aCollector->registerMetric(new pm::Metric(cpuLoad, cpuLoadUser, 0)); … … 11507 11534 new pm::AggregateMin())); 11508 11535 aCollector->registerMetric(new pm::Metric(ramUsage, ramUsageUsed, 11536 new pm::AggregateMax())); 11537 11538 aCollector->registerMetric(new pm::Metric(diskUsage, diskUsageUsed, 0)); 11539 aCollector->registerMetric(new pm::Metric(diskUsage, diskUsageUsed, 11540 new pm::AggregateAvg())); 11541 aCollector->registerMetric(new pm::Metric(diskUsage, diskUsageUsed, 11542 new pm::AggregateMin())); 11543 aCollector->registerMetric(new pm::Metric(diskUsage, diskUsageUsed, 11509 11544 new pm::AggregateMax())); 11510 11545 -
trunk/src/VBox/Main/src-server/Performance.cpp
r43908 r43949 25 25 #include "VirtualBoxImpl.h" 26 26 #include "MachineImpl.h" 27 #include "MediumImpl.h" 28 #include "AutoCaller.h" 27 29 #endif 28 30 #include "Performance.h" … … 1006 1008 1007 1009 #ifndef VBOX_COLLECTOR_TEST_CASE 1010 void MachineDiskUsage::init(ULONG period, ULONG length) 1011 { 1012 mPeriod = period; 1013 mLength = length; 1014 mUsed->init(mLength); 1015 } 1016 1017 void MachineDiskUsage::preCollect(CollectorHints& /* hints */, uint64_t /* iTick */) 1018 { 1019 } 1020 1021 void MachineDiskUsage::collect() 1022 { 1023 ULONG used = 0; 1024 1025 for (MediaList::iterator it = mDisks.begin(); it != mDisks.end(); ++it) 1026 { 1027 ComObjPtr<Medium> pMedium = *it; 1028 1029 /* just in case */ 1030 AssertStmt(!pMedium.isNull(), continue); 1031 1032 AutoCaller localAutoCaller(pMedium); 1033 if (FAILED(localAutoCaller.rc())) continue; 1034 1035 AutoReadLock local_alock(pMedium COMMA_LOCKVAL_SRC_POS); 1036 1037 used += pMedium->getSize() / (1024 * 1024); 1038 } 1039 1040 mUsed->put(used); 1041 } 1042 1008 1043 void MachineNetRate::init(ULONG period, ULONG length) 1009 1044 {
Note:
See TracChangeset
for help on using the changeset viewer.