From a26b58ec8e56447c0de44190f41862cdbfed925d Mon Sep 17 00:00:00 2001 From: Shimin Guo Date: Fri, 15 Jan 2016 08:40:20 -0800 Subject: [PATCH] expose page cache size --- container/libcontainer/helpers.go | 1 + info/v1/container.go | 4 ++++ metrics/prometheus.go | 7 +++++++ 3 files changed, 12 insertions(+) diff --git a/container/libcontainer/helpers.go b/container/libcontainer/helpers.go index 116ae034..e35cb8a5 100644 --- a/container/libcontainer/helpers.go +++ b/container/libcontainer/helpers.go @@ -378,6 +378,7 @@ func toContainerStats1(s *cgroups.Stats, ret *info.ContainerStats) { func toContainerStats2(s *cgroups.Stats, ret *info.ContainerStats) { ret.Memory.Usage = s.MemoryStats.Usage.Usage ret.Memory.Failcnt = s.MemoryStats.Usage.Failcnt + ret.Memory.Cache = s.MemoryStats.Stats["cache"] ret.Memory.RSS = s.MemoryStats.Stats["rss"] if v, ok := s.MemoryStats.Stats["pgfault"]; ok { ret.Memory.ContainerData.Pgfault = v diff --git a/info/v1/container.go b/info/v1/container.go index 44d5c32f..61d64bcb 100644 --- a/info/v1/container.go +++ b/info/v1/container.go @@ -308,6 +308,10 @@ type MemoryStats struct { // Units: Bytes. Usage uint64 `json:"usage"` + // Number of bytes of page cache memory. + // Units: Bytes. + Cache uint64 `json:"cache"` + // The amount of anonymous and swap cache memory (includes transparent // hugepages). // Units: Bytes. diff --git a/metrics/prometheus.go b/metrics/prometheus.go index 410869bc..89fb91f5 100644 --- a/metrics/prometheus.go +++ b/metrics/prometheus.go @@ -127,6 +127,13 @@ func NewPrometheusCollector(infoProvider infoProvider, f ContainerNameToLabelsFu } return values }, + }, { + name: "container_memory_cache", + help: "Number of bytes of page cache memory.", + valueType: prometheus.GaugeValue, + getValues: func(s *info.ContainerStats) metricValues { + return metricValues{{value: float64(s.Memory.Cache)}} + }, }, { name: "container_memory_rss", help: "Size of RSS in bytes",