diff options
| author | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-07 16:01:35 +0100 |
|---|---|---|
| committer | Hazel Atkinson <yellowsink@riseup.net> | 2025-04-07 16:01:35 +0100 |
| commit | beb6d6feb581b60c98b461c11b92d8a6708c91d8 (patch) | |
| tree | d5dee95ac3f74baad00efe85bcb208a83c69fd55 /src/stats_task.rs | |
| parent | cd5fbac13f68d2e054632570bb3520f9a3ff8e42 (diff) | |
| download | containerspy-beb6d6feb581b60c98b461c11b92d8a6708c91d8.tar.gz containerspy-beb6d6feb581b60c98b461c11b92d8a6708c91d8.tar.bz2 containerspy-beb6d6feb581b60c98b461c11b92d8a6708c91d8.zip | |
[wip] im confused by memory
Diffstat (limited to 'src/stats_task.rs')
| -rw-r--r-- | src/stats_task.rs | 43 |
1 files changed, 41 insertions, 2 deletions
diff --git a/src/stats_task.rs b/src/stats_task.rs index 8b82373..47e93e2 100644 --- a/src/stats_task.rs +++ b/src/stats_task.rs @@ -1,5 +1,5 @@ use std::mem::MaybeUninit; -use bollard::container::{BlkioStatsEntry, StatsOptions}; +use bollard::container::{BlkioStatsEntry, MemoryStatsStats, MemoryStatsStatsV1, StatsOptions}; use bollard::models::ContainerSummary; use bollard::Docker; use opentelemetry::metrics::MeterProvider; @@ -211,7 +211,46 @@ pub fn launch_stats_task( } meter_container_last_seen.record(SystemTime::now().duration_since(UNIX_EPOCH).unwrap().as_secs(), shared_labels); - } else { + + // cgroups values references: + // - https://github.com/docker/cli/blob/91cbde67/cli/command/container/stats_helpers.go#L230-L231 + // - https://github.com/google/cadvisor/blob/f6e31a3c/info/v1/container.go#L389 (yes, v1, roll w it) + // - https://www.kernel.org/doc/html/latest/admin-guide/cgroup-v2.html + + if let Some(all_usage) = stats.memory_stats.usage { + if cfg!(windows) { + // todo + // i have no way to test cgroups v2 so only work on v1 - see readme for more info + } else if let Some(MemoryStatsStats::V2(v2stats)) = stats.memory_stats.stats { + // container_memory_cache + + + // container_memory_failcnt only on cgroups v1 + + // container_memory_failures_total + v2stats.pgfault; // label failure_type=pgfault + v2stats.pgmajfault; // label failure_type=pgmajfault + + // container_memory_mapped_file + v2stats.file; // includes tmpfs + + // container_memory_max_usage_bytes only on cgroups v1 + + // container_memory_migrate + + + // container_memory_numa_pages omitted cause its hard :< + + // container_memory_rss: may need recalcing + + // container_memory_swap: can't get + + // container_memory_usage_bytes: how? + + // container_memory_working_set_bytes: not reported + } + } + } else { // failed to get stats, log as such: // TODO: use json logging or syslog so loki can understand this lol println!( |
