boondock icon indicating copy to clipboard operation
boondock copied to clipboard

How to inspect stats when a kernel feature is disabled?

Open gcavalcante8808 opened this issue 7 years ago • 3 comments

Hi Folks,

In these days, much of the linux kernels running doesnt have the Cgroup Swap support activated and because of this, there is no field called 'swap' for the container stats. When I try to gather some container stats with the following code

    for container in &containers {
        let _stats = match docker.stats(container) {
            Ok(stats) => stats,
            Err(e) => { panic!("{}", e); }
        };

        for stat in _stats{
            println!("{:?}", stat);
        }
    }

It returns to me the message "(Some(Error("missing field swap", line: 1, column: 4183)), None)))".

Thanks in advance.

gcavalcante8808 avatar Aug 28 '18 23:08 gcavalcante8808

Take a look at https://github.com/faradayio/boondock/pull/20 , perhaps that fixes the error..

fussybeaver avatar Aug 29 '18 09:08 fussybeaver

Yeah, I can confirm that. In my case, the following changes on structs fixed the problem:

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Stats {
    pub read: String,
    pub network: Option<Network>,
    pub memory_stats: MemoryStats,
    pub cpu_stats: CpuStats,
    pub blkio_stats: BlkioStats
}


#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MemoryStat {
    pub total_pgmajfault: u64,
    pub cache: u64,
    pub mapped_file: u64,
    pub total_inactive_file: u64,
    pub pgpgout: u64,
    pub rss: u64,
    pub total_mapped_file: u64,
    pub writeback: u64,
    pub unevictable: u64,
    pub pgpgin: u64,
    pub total_unevictable: u64,
    pub pgmajfault: u64,
    pub total_rss: u64,
    pub total_rss_huge: u64,
    pub total_writeback: u64,
    pub total_inactive_anon: u64,
    pub rss_huge: u64,
    pub hierarchical_memory_limit: u64,
    pub hierarchical_memsw_limit: u64,
    pub total_pgfault: u64,
    pub total_active_file: u64,
    pub active_anon: u64,
    pub total_active_anon: u64,
    pub total_pgpgout: u64,
    pub total_cache: u64,
    pub inactive_anon: u64,
    pub active_file: u64,
    pub pgfault: u64,
    pub inactive_file: u64,
    pub total_pgpgin: u64,
    pub swap: Option<u64>,
    pub total_swap: Option<u64>
}

As I can see, there is no conflicts on the https://github.com/faradayio/boondock/pull/20 PR. Is there any plans to merge it?

gcavalcante8808 avatar Aug 29 '18 11:08 gcavalcante8808

Thank you for figuring this out!

Please see my note on this PR about the maintenance schedule for boondock: https://github.com/faradayio/boondock/pull/21. TL;dr: I've been juggling other stuff lately, but I hope to get back around to it soon.

emk avatar Oct 03 '18 13:10 emk