add swap metrics (#2333)

This commit is contained in:
Alex Sharov 2021-07-10 12:19:29 +07:00 committed by GitHub
parent e340fa0deb
commit 7cbe6e9f28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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))