MCPcopy Create free account
hub / github.com/apple/foundationdb / initPdhStrings

Function initPdhStrings

flow/Platform.actor.cpp:1436–1516  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1434
1435#if defined(_WIN32)
1436void initPdhStrings(SystemStatisticsState* state, std::string dataFolder) {
1437 if (setPdhString(234, state->pdhStrings.physicalDisk) && setPdhString(238, state->pdhStrings.processor) &&
1438 setPdhString(510, state->pdhStrings.networkDevice) && setPdhString(638, state->pdhStrings.tcpv4) &&
1439 setPdhString(1482, state->pdhStrings.pctIdle) && setPdhString(198, state->pdhStrings.diskQueueLength) &&
1440 setPdhString(214, state->pdhStrings.diskReadsPerSec) && setPdhString(216, state->pdhStrings.diskWritesPerSec) &&
1441 setPdhString(222, state->pdhStrings.diskWriteBytesPerSec) &&
1442 setPdhString(506, state->pdhStrings.bytesSentPerSec) && setPdhString(264, state->pdhStrings.bytesRecvPerSec) &&
1443 setPdhString(654, state->pdhStrings.segmentsOutPerSec) &&
1444 setPdhString(656, state->pdhStrings.segmentsRetransPerSec)) {
1445
1446 if (!dataFolder.empty()) {
1447 dataFolder = abspath(dataFolder);
1448 char buf[512], buf2[512];
1449 DWORD sz = 512, sz2 = 512;
1450
1451 if (!GetVolumePathName(dataFolder.c_str(), buf, 512)) {
1452 TraceEvent(SevWarn, "GetVolumePathName").GetLastError().detail("Path", dataFolder);
1453 return;
1454 }
1455
1456 if (!GetVolumeNameForVolumeMountPoint(buf, buf2, 512)) {
1457 TraceEvent(SevWarn, "GetVolumeNameForVolumeMountPoint").GetLastError().detail("Path", dataFolder);
1458 return;
1459 }
1460
1461 if (!strlen(buf2)) {
1462 TraceEvent(SevWarn, "WinDiskStatsGetPathError").detail("Path", dataFolder);
1463 return;
1464 }
1465
1466 if (buf2[strlen(buf2) - 1] == '\\')
1467 buf2[strlen(buf2) - 1] = 0;
1468
1469 HANDLE hDevice = CreateFile(buf2, 0, 0, nullptr, OPEN_EXISTING, 0, nullptr);
1470 if (hDevice == INVALID_HANDLE_VALUE) {
1471 TraceEvent(SevWarn, "CreateFile").GetLastError().detail("Path", dataFolder);
1472 return;
1473 }
1474
1475 STORAGE_DEVICE_NUMBER storage_device;
1476 if (!DeviceIoControl(hDevice,
1477 IOCTL_STORAGE_GET_DEVICE_NUMBER,
1478 nullptr,
1479 0,
1480 &storage_device,
1481 sizeof(storage_device),
1482 &sz,
1483 nullptr)) {
1484 TraceEvent(SevWarn, "DeviceIoControl").GetLastError().detail("Path", dataFolder);
1485 return;
1486 }
1487
1488 // Find the drive letter involved!
1489 sz = 512;
1490 if (handlePdhStatus(PdhEnumObjectItems(nullptr,
1491 nullptr,
1492 state->pdhStrings.physicalDisk.c_str(),
1493 buf2,

Callers 1

getSystemStatisticsFunction · 0.85

Calls 7

setPdhStringFunction · 0.85
TraceEventClass · 0.85
handlePdhStatusFunction · 0.85
detailMethod · 0.80
abspathFunction · 0.70
emptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected