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

Function getSystemStatistics

flow/Platform.actor.cpp:1519–1768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1517#endif
1518
1519SystemStatistics getSystemStatistics(std::string const& dataFolder,
1520 const IPAddress* ip,
1521 SystemStatisticsState** statState,
1522 bool logDetails) {
1523 if ((*statState) == nullptr)
1524 (*statState) = new SystemStatisticsState();
1525 SystemStatistics returnStats;
1526
1527 double nowTime = timer();
1528 double nowClockProcess = getProcessorTimeProcess();
1529 double nowClockThread = getProcessorTimeThread();
1530 returnStats.elapsed = nowTime - (*statState)->lastTime;
1531
1532 returnStats.initialized = (*statState)->lastTime != 0;
1533 if (returnStats.initialized) {
1534 returnStats.processCPUSeconds = (nowClockProcess - (*statState)->lastClockProcess);
1535 returnStats.mainThreadCPUSeconds = (nowClockThread - (*statState)->lastClockThread);
1536 }
1537
1538 returnStats.processMemory = getMemoryUsage();
1539 returnStats.processResidentMemory = getResidentMemoryUsage();
1540
1541 MachineRAMInfo memInfo;
1542 getMachineRAMInfo(memInfo);
1543 returnStats.machineTotalRAM = memInfo.total;
1544 returnStats.machineCommittedRAM = memInfo.committed;
1545 returnStats.machineAvailableRAM = memInfo.available;
1546
1547 if (dataFolder != "") {
1548 int64_t diskTotal, diskFree;
1549 getDiskBytes(dataFolder, diskFree, diskTotal);
1550 returnStats.processDiskTotalBytes = diskTotal;
1551 returnStats.processDiskFreeBytes = diskFree;
1552 }
1553
1554#if defined(_WIN32)
1555 if ((*statState)->Query == nullptr) {
1556 initPdhStrings(*statState, dataFolder);
1557
1558 TraceEvent("SetupQuery").log();
1559 handlePdhStatus(PdhOpenQuery(nullptr, NULL, &(*statState)->Query), "PdhOpenQuery");
1560
1561 if (!(*statState)->pdhStrings.diskDevice.empty()) {
1562 handlePdhStatus(
1563 PdhAddCounter((*statState)->Query,
1564 ("\\" + (*statState)->pdhStrings.physicalDisk + "(" +
1565 (*statState)->pdhStrings.diskDevice + ")\\" + (*statState)->pdhStrings.pctIdle)
1566 .c_str(),
1567 0,
1568 &(*statState)->DiskTimeCounter),
1569 "PdhAddCounter");
1570 handlePdhStatus(
1571 PdhAddCounter((*statState)->Query,
1572 ("\\" + (*statState)->pdhStrings.physicalDisk + "(" +
1573 (*statState)->pdhStrings.diskDevice + ")\\" + (*statState)->pdhStrings.diskQueueLength)
1574 .c_str(),
1575 0,
1576 &(*statState)->QueueLengthCounter),

Callers

nothing calls this directly

Calls 15

getProcessorTimeProcessFunction · 0.85
getProcessorTimeThreadFunction · 0.85
getMemoryUsageFunction · 0.85
getResidentMemoryUsageFunction · 0.85
getMachineRAMInfoFunction · 0.85
initPdhStringsFunction · 0.85
TraceEventClass · 0.85
handlePdhStatusFunction · 0.85
addCountersFunction · 0.85
getNetworkTrafficFunction · 0.85
getDiskStatisticsFunction · 0.85
getMachineLoadFunction · 0.85

Tested by

no test coverage detected