- Timestamp:
- Nov 26, 2012 10:37:06 AM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 82302
- Location:
- trunk/src/VBox/Main
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/include/Performance.h
r43949 r43958 373 373 /** Returns file system counters in megabytes. */ 374 374 virtual int getHostFilesystemUsage(const char *name, ULONG *total, ULONG *used, ULONG *available); 375 /** Returns disk size in bytes. */ 376 virtual int getHostDiskSize(const char *name, uint64_t *size); 375 377 /** Returns CPU usage in 1/1000th per cent by a particular process. */ 376 378 virtual int getProcessCpuLoad(RTPROCESS process, ULONG *user, ULONG *kernel); … … 582 584 SubMetric *mUsed; 583 585 SubMetric *mAvailable; 586 }; 587 588 class HostDiskUsage : public BaseMetric 589 { 590 public: 591 HostDiskUsage(CollectorHAL *hal, ComPtr<IUnknown> object, com::Utf8Str name, com::Utf8Str diskname, SubMetric *total) 592 : BaseMetric(hal, name, object), mDiskName(diskname), mTotal(total) {}; 593 ~HostDiskUsage() { delete mTotal; }; 594 595 void init(ULONG period, ULONG length); 596 void preCollect(CollectorHints& hints, uint64_t iTick); 597 void collect(); 598 const char *getUnit() { return "mB"; }; 599 ULONG getMinValue() { return 0; }; 600 ULONG getMaxValue() { return INT32_MAX; }; 601 ULONG getScale() { return 1; } 602 private: 603 com::Utf8Str mDiskName; 604 SubMetric *mTotal; 584 605 }; 585 606 -
trunk/src/VBox/Main/src-server/HostImpl.cpp
r43831 r43958 2936 2936 for (it = disks.begin(); it != disks.end(); ++it) 2937 2937 { 2938 Utf8StrFmt strName("Disk/%s /Load", it->c_str());2939 pm::SubMetric *fsLoadUtil = new pm::SubMetric(strName + "/ Util",2938 Utf8StrFmt strName("Disk/%s", it->c_str()); 2939 pm::SubMetric *fsLoadUtil = new pm::SubMetric(strName + "/Load/Util", 2940 2940 "Percentage of time disk was busy serving I/O requests."); 2941 pm::BaseMetric *fsLoad = new pm::HostDiskLoadRaw(hal, this, strName, 2941 pm::SubMetric *fsUsageTotal = new pm::SubMetric(strName + "/Usage/Total", 2942 "Disk size."); 2943 pm::BaseMetric *fsLoad = new pm::HostDiskLoadRaw(hal, this, strName + "/Load", 2942 2944 *it, fsLoadUtil); 2943 2945 aCollector->registerBaseMetric (fsLoad); 2946 pm::BaseMetric *fsUsage = new pm::HostDiskUsage(hal, this, strName + "/Usage", 2947 *it, fsUsageTotal); 2948 aCollector->registerBaseMetric (fsUsage); 2944 2949 2945 2950 aCollector->registerMetric(new pm::Metric(fsLoad, fsLoadUtil, 0)); … … 2949 2954 new pm::AggregateMin())); 2950 2955 aCollector->registerMetric(new pm::Metric(fsLoad, fsLoadUtil, 2956 new pm::AggregateMax())); 2957 2958 aCollector->registerMetric(new pm::Metric(fsUsage, fsUsageTotal, 0)); 2959 aCollector->registerMetric(new pm::Metric(fsUsage, fsUsageTotal, 2960 new pm::AggregateAvg())); 2961 aCollector->registerMetric(new pm::Metric(fsUsage, fsUsageTotal, 2962 new pm::AggregateMin())); 2963 aCollector->registerMetric(new pm::Metric(fsUsage, fsUsageTotal, 2951 2964 new pm::AggregateMax())); 2952 2965 } -
trunk/src/VBox/Main/src-server/Performance.cpp
r43949 r43958 82 82 83 83 int CollectorHAL::getHostFilesystemUsage(const char * /* name */, ULONG * /* total */, ULONG * /* used */, ULONG * /* available */) 84 { 85 return E_NOTIMPL; 86 } 87 88 int CollectorHAL::getHostDiskSize(const char * /* name */, uint64_t * /* size */) 84 89 { 85 90 return E_NOTIMPL; … … 859 864 } 860 865 866 void HostDiskUsage::init(ULONG period, ULONG length) 867 { 868 mPeriod = period; 869 mLength = length; 870 mTotal->init(mLength); 871 } 872 873 void HostDiskUsage::preCollect(CollectorHints& /* hints */, uint64_t /* iTick */) 874 { 875 } 876 877 void HostDiskUsage::collect() 878 { 879 uint64_t total; 880 int rc = mHAL->getHostDiskSize(mDiskName.c_str(), &total); 881 if (RT_SUCCESS(rc)) 882 mTotal->put((ULONG)(total / (1024*1024))); 883 } 884 861 885 #ifndef VBOX_COLLECTOR_TEST_CASE 862 886 void HostRamVmm::init(ULONG period, ULONG length) -
trunk/src/VBox/Main/src-server/linux/PerformanceLinux.cpp
r43845 r43958 49 49 virtual int getHostMemoryUsage(ULONG *total, ULONG *used, ULONG *available); 50 50 virtual int getHostFilesystemUsage(const char *name, ULONG *total, ULONG *used, ULONG *available); 51 virtual int getHostDiskSize(const char *name, uint64_t *size); 51 52 virtual int getProcessMemoryUsage(RTPROCESS process, ULONG *used); 52 53 … … 242 243 } 243 244 245 int CollectorLinux::getHostDiskSize(const char *name, uint64_t *size) 246 { 247 int rc = VINF_SUCCESS; 248 char *pszName = NULL; 249 long long unsigned int u64Size; 250 251 RTStrAPrintf(&pszName, "/sys/block/%s/size", name); 252 Assert(pszName); 253 FILE *f = fopen(pszName, "r"); 254 RTMemFree(pszName); 255 256 if (f) 257 { 258 if (fscanf(f, "%llu", &u64Size) == 1) 259 *size = u64Size * 512; 260 else 261 rc = VERR_FILE_IO_ERROR; 262 fclose(f); 263 } 264 else 265 rc = VERR_ACCESS_DENIED; 266 267 return rc; 268 } 269 244 270 int CollectorLinux::getProcessMemoryUsage(RTPROCESS process, ULONG *used) 245 271 { -
trunk/src/VBox/Main/testcase/tstCollector.cpp
r43844 r43958 231 231 { 232 232 RTPrintf("tstCollector: getDiskListByFs(%s) returned empty list\n", FSNAME); 233 return 1; 234 } 235 236 uint64_t diskSize = 0; 237 rc = collector->getHostDiskSize(disks.front().c_str(), &diskSize); 238 RTPrintf("tstCollector: TESTING - Disk size (%s) = %llu\n", disks.front().c_str(), diskSize); 239 if (RT_FAILURE(rc)) 240 { 241 RTPrintf("tstCollector: getHostDiskSize() -> %Rrc\n", rc); 233 242 return 1; 234 243 }
Note:
See TracChangeset
for help on using the changeset viewer.