- Timestamp:
- Nov 8, 2012 4:51:46 PM (12 years ago)
- Location:
- trunk/src/VBox/Main
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Main/src-server/linux/PerformanceLinux.cpp
r43840 r43842 62 62 char *getDiskName(char *pszDiskName, size_t cbDiskName, const char *pszDevName, bool fTrimDigits); 63 63 void addVolumeDependencies(const char *pcszVolume, DiskList& listDisks); 64 char *trimTrailingDigits(char *pszName); 64 65 65 66 struct VMProcessStats … … 332 333 int CollectorLinux::getRawHostDiskLoad(const char *name, uint64_t *disk_ms, uint64_t *total_ms) 333 334 { 335 #if 0 334 336 int rc = VINF_SUCCESS; 335 337 char szIfName[/*IFNAMSIZ*/ 16 + 36]; … … 352 354 else 353 355 rc = VERR_ACCESS_DENIED; 356 #else 357 int rc = VERR_MISSING; 358 FILE *f = fopen("/proc/diskstats", "r"); 359 if (f) 360 { 361 char szBuf[128]; 362 while (fgets(szBuf, sizeof(szBuf), f)) 363 { 364 char *pszBufName = &szBuf[13]; 365 char *pszBufData = strchr(pszBufName, ' '); 366 if (!pszBufData) 367 { 368 LogRel(("CollectorLinux::getRawHostDiskLoad() failed to parse disk stats: %s\n", szBuf)); 369 continue; 370 } 371 *pszBufData++ = '\0'; 372 if (!strcmp(name, pszBufName)) 373 { 374 long long unsigned int u64Busy, tmp; 375 376 if (sscanf(pszBufData, "%llu %llu %llu %llu %llu %llu %llu %llu %llu %llu %llu", 377 &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &tmp, &u64Busy, &tmp) == 11) 378 { 379 *disk_ms = u64Busy; 380 *total_ms = (uint64_t)(mSingleUser + mSingleKernel + mSingleIdle) * 1000 / mHZ; 381 rc = VINF_SUCCESS; 382 } 383 else 384 rc = VERR_FILE_IO_ERROR; 385 break; 386 } 387 } 388 fclose(f); 389 } 390 #endif 354 391 355 392 return rc; 393 } 394 395 char *CollectorLinux::trimTrailingDigits(char *pszName) 396 { 397 unsigned cbName = strlen(pszName); 398 if (cbName == 0) 399 return pszName; 400 401 char *pszEnd = pszName + cbName - 1; 402 while (pszEnd > pszName && RT_C_IS_DIGIT(*pszEnd)) 403 pszEnd--; 404 pszEnd[1] = '\0'; 405 406 return pszName; 356 407 } 357 408 … … 380 431 { 381 432 LogRel(("VolInfo: Failed to get program path, rc=%Rrc\n", rc)); 382 return VERR_INVALID_PARAMETER;433 return; 383 434 } 384 435 strcat(szVolInfo, "/" VBOXVOLINFO_NAME " "); … … 391 442 392 443 while (fgets(szBuf, sizeof(szBuf), fp)) 393 listDisks.push_back(RTCString( szBuf));444 listDisks.push_back(RTCString(trimTrailingDigits(szBuf))); 394 445 395 446 pclose(fp); -
trunk/src/VBox/Main/testcase/tstCollector.cpp
r43835 r43842 314 314 return 1; 315 315 } 316 #if 1316 #if 0 317 317 pm::CollectorHints hints; 318 318 hints.collectHostCpuLoad(); … … 482 482 rc = testDisk(collector); 483 483 #endif 484 #if 1484 #if 0 485 485 RTPrintf("tstCollector: TESTING - Performance\n\n"); 486 486
Note:
See TracChangeset
for help on using the changeset viewer.