Skip to content

Commit 4ccc30c

Browse files
authored
[OMON-378] Add voluntary context switches to process monitoring (#217)
1 parent 37d4454 commit 4ccc30c

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ endif()
1717

1818
# Define project
1919
project(Monitoring
20-
VERSION 3.3.4
20+
VERSION 3.4.0
2121
DESCRIPTION "O2 Monitoring library"
2222
LANGUAGES CXX
2323
)

include/Monitoring/ProcessMonitor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ class ProcessMonitor
4242
VIRTUAL_MEMORY_SIZE,
4343
RESIDENT_SET_SIZE,
4444
CPU_USED_PERCENTAGE,
45-
INVOLUNTARY_CONTEXT_SWITCHING,
45+
INVOLUNTARY_CONTEXT_SWITCHES,
46+
VOLUNTARY_CONTEXT_SWITCHES,
4647
CPU_USED_ABSOLUTE,
4748
AVG_RESIDENT_SET_SIZE,
4849
AVG_VIRTUAL_MEMORY_SIZE,
@@ -72,7 +73,7 @@ class ProcessMonitor
7273

7374
private:
7475
static constexpr const char* metricsNames[] = {"memoryUsagePercentage", "virtualMemorySize", "residentSetSize",
75-
"cpuUsedPercentage", "involuntaryContextSwitches", "cpuUsedAbsolute",
76+
"cpuUsedPercentage", "involuntaryContextSwitches", "voluntaryContextSwitches", "cpuUsedAbsolute",
7677
"averageResidentSetSize", "averageVirtualMemorySize", "averageCpuUsedPercentage",
7778
"cpuTimeConsumedByProcess", "proportionalSetSize"};
7879

src/ProcessMonitor.cxx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ std::vector<Metric> ProcessMonitor::getCpuAndContexts()
108108

109109
metrics.emplace_back(Metric{cpuUsedPerctange, metricsNames[CPU_USED_PERCENTAGE]});
110110
metrics.emplace_back(Metric{
111-
static_cast<uint64_t>(currentUsage.ru_nivcsw - mPreviousGetrUsage.ru_nivcsw), metricsNames[INVOLUNTARY_CONTEXT_SWITCHING]});
111+
static_cast<uint64_t>(currentUsage.ru_nivcsw - mPreviousGetrUsage.ru_nivcsw), metricsNames[INVOLUNTARY_CONTEXT_SWITCHES]});
112+
metrics.emplace_back(Metric{
113+
static_cast<uint64_t>(currentUsage.ru_nvcsw - mPreviousGetrUsage.ru_nvcsw), metricsNames[VOLUNTARY_CONTEXT_SWITCHES]});
112114
metrics.emplace_back(cpuUsedInMicroSeconds, metricsNames[CPU_USED_ABSOLUTE]);
113115

114116
mTimeLastRun = timeNow;

0 commit comments

Comments
 (0)