From 7cbe6e9f28d35ae1ffac6ec595a3951d4d31fe21 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Sat, 10 Jul 2021 12:19:29 +0700 Subject: [PATCH] add swap metrics (#2333) --- metrics/metrics.go | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/metrics/metrics.go b/metrics/metrics.go index ac9eddd37..6ce8de329 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -133,15 +133,18 @@ func CollectProcessMetrics(refresh time.Duration) { memLocked = GetOrRegisterGauge("mem/locked", DefaultRegistry) memSwap = GetOrRegisterGauge("mem/swap", DefaultRegistry) - vmemTotal = GetOrRegisterGauge("vmem/total", DefaultRegistry) - vmemAvailable = GetOrRegisterGauge("vmem/available", DefaultRegistry) - vmemUsed = GetOrRegisterGauge("vmem/used", DefaultRegistry) - vmemBuffers = GetOrRegisterGauge("vmem/buffers", DefaultRegistry) - vmemCached = GetOrRegisterGauge("vmem/cached", DefaultRegistry) - vmemWriteBack = GetOrRegisterGauge("vmem/writeback", DefaultRegistry) - vmemDirty = GetOrRegisterGauge("vmem/dirty", DefaultRegistry) - vmemShared = GetOrRegisterGauge("vmem/shared", DefaultRegistry) - vmemMapped = GetOrRegisterGauge("vmem/mapped", DefaultRegistry) + vmemTotal = GetOrRegisterGauge("vmem/total", DefaultRegistry) + vmemAvailable = GetOrRegisterGauge("vmem/available", DefaultRegistry) + vmemUsed = GetOrRegisterGauge("vmem/used", DefaultRegistry) + vmemBuffers = GetOrRegisterGauge("vmem/buffers", DefaultRegistry) + vmemCached = GetOrRegisterGauge("vmem/cached", DefaultRegistry) + vmemWriteBack = GetOrRegisterGauge("vmem/writeback", DefaultRegistry) + vmemDirty = GetOrRegisterGauge("vmem/dirty", DefaultRegistry) + vmemShared = GetOrRegisterGauge("vmem/shared", DefaultRegistry) + vmemMapped = GetOrRegisterGauge("vmem/mapped", DefaultRegistry) + vmemSwapped = GetOrRegisterGauge("vmem/swapped", DefaultRegistry) + vmemVmallocUsed = GetOrRegisterGauge("vmem/vmalloc/used", DefaultRegistry) + vmemVmallocChunk = GetOrRegisterGauge("vmem/vmalloc/chunk", DefaultRegistry) ) p, _ := process.NewProcess(int32(os.Getpid())) @@ -177,23 +180,9 @@ func CollectProcessMetrics(refresh time.Duration) { vmemDirty.Update(int64(m.Dirty)) vmemShared.Update(int64(m.Shared)) vmemMapped.Update(int64(m.Mapped)) - - //Slab uint64 `json:"slab"` - //Sreclaimable uint64 `json:"sreclaimable"` - //Sunreclaim uint64 `json:"sunreclaim"` - //PageTables uint64 `json:"pageTables"` - //SwapCached uint64 `json:"swapCached"` - //CommitLimit uint64 `json:"commitLimit"` - //CommittedAS uint64 `json:"committedAS"` - //HighTotal uint64 `json:"highTotal"` - //HighFree uint64 `json:"highFree"` - //LowTotal uint64 `json:"lowTotal"` - //LowFree uint64 `json:"lowFree"` - //SwapTotal uint64 `json:"swapTotal"` - //SwapFree uint64 `json:"swapFree"` - //VmallocTotal uint64 `json:"vmallocTotal"` - //VmallocUsed uint64 `json:"vmallocUsed"` - //VmallocChunk uint64 `json:"vmallocChunk"` + vmemSwapped.Update(int64(m.SwapCached)) + vmemVmallocUsed.Update(int64(m.VmallocUsed)) + vmemVmallocChunk.Update(int64(m.VmallocChunk)) } if m, _ := p.MemoryInfo(); m != nil { memRSS.Update(int64(m.RSS))