Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cgroup v2 CPU & memory stats for correct chart generation #65

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions collector/src/cgroups_cpuacct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@

bool CMonitorCgroups::read_cpuset_cpus(std::string kernelPath, std::set<uint64_t>& cpus)
{
std::set<uint64_t> empty_set;
return read_integers_with_range_validation(kernelPath + "/cpuset.cpus", 0, INT32_MAX, cpus);
if (m_nCGroupsFound == CG_NONE)
return false;

std::string cpuset_path = kernelPath + ((m_nCGroupsFound == CG_VERSION2)? "/cpuset.cpus.effective" : "/cpuset.cpus");

return read_integers_with_range_validation(cpuset_path, 0, INT32_MAX, cpus);
}

bool CMonitorCgroups::read_cpuacct_line(FastFileReader& reader, std::vector<uint64_t>& valuesINT /* OUT */)
Expand Down
2 changes: 1 addition & 1 deletion collector/src/cgroups_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void CMonitorCgroups::sample_memory(
case CG_VERSION2: {
key_value_map_t newEventsValues;
if (sample_flat_keyed_file(m_cgroup_memory_v2_events, allowedStatsNames, "events.", newEventsValues)) {
if (print) {
if (print) {
for (auto entry : newEventsValues) {
auto prevValue = m_memory_prev_values.v2_events.find(entry.first);
if (prevValue != m_memory_prev_values.v2_events.end())
Expand Down
2 changes: 2 additions & 0 deletions collector/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,8 @@ int CMonitorCollectorApp::run_main_loop()
charted_stats_from_cgroup_memory_v1.insert("failcnt");
// cgroups v2
charted_stats_from_cgroup_memory_v2.insert("stat.anon");
charted_stats_from_cgroup_memory_v2.insert("stat.file");
charted_stats_from_cgroup_memory_v2.insert("events.oom_kill");
}
// else: leave empty

Expand Down