From 6ad50893612886d7c75127844461fb05b6706b2f Mon Sep 17 00:00:00 2001 From: shrug42 <40281011+shrug42@users.noreply.github.com> Date: Mon, 13 Aug 2018 16:41:23 -0700 Subject: [PATCH] Add gopsutil meminfo fields to mem plugin (#4546) --- Gopkg.lock | 4 +-- Gopkg.toml | 2 +- plugins/inputs/mem/memory.go | 21 ++++++++++++++++ plugins/inputs/mem/memory_test.go | 42 +++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 4a70b057d..ce842f3e1 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -856,8 +856,8 @@ "process", ] pruneopts = "" - revision = "4a180b209f5f494e5923cfce81ea30ba23915877" - version = "v2.18.06" + revision = "8048a2e9c5773235122027dd585cf821b2af1249" + version = "v2.18.07" [[projects]] branch = "master" diff --git a/Gopkg.toml b/Gopkg.toml index 799b5243c..d282e1ebd 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -148,7 +148,7 @@ [[constraint]] name = "github.com/shirou/gopsutil" - version = "2.18.05" + version = "2.18.07" [[constraint]] name = "github.com/Shopify/sarama" diff --git a/plugins/inputs/mem/memory.go b/plugins/inputs/mem/memory.go index f664dd3f4..a7d887cbe 100644 --- a/plugins/inputs/mem/memory.go +++ b/plugins/inputs/mem/memory.go @@ -37,6 +37,27 @@ func (s *MemStats) Gather(acc telegraf.Accumulator) error { "slab": vm.Slab, "used_percent": 100 * float64(vm.Used) / float64(vm.Total), "available_percent": 100 * float64(vm.Available) / float64(vm.Total), + "commit_limit": vm.CommitLimit, + "committed_as": vm.CommittedAS, + "dirty": vm.Dirty, + "high_free": vm.HighFree, + "high_total": vm.HighTotal, + "huge_page_size": vm.HugePageSize, + "huge_pages_free": vm.HugePagesFree, + "huge_pages_total": vm.HugePagesTotal, + "low_free": vm.LowFree, + "low_total": vm.LowTotal, + "mapped": vm.Mapped, + "page_tables": vm.PageTables, + "shared": vm.Shared, + "swap_cached": vm.SwapCached, + "swap_free": vm.SwapFree, + "swap_total": vm.SwapTotal, + "vmalloc_chunk": vm.VMallocChunk, + "vmalloc_total": vm.VMallocTotal, + "vmalloc_used": vm.VMallocUsed, + "write_back": vm.Writeback, + "write_back_tmp": vm.WritebackTmp, } acc.AddGauge("mem", fields, nil) diff --git a/plugins/inputs/mem/memory_test.go b/plugins/inputs/mem/memory_test.go index ef9af8d22..06f2f6ea9 100644 --- a/plugins/inputs/mem/memory_test.go +++ b/plugins/inputs/mem/memory_test.go @@ -27,6 +27,27 @@ func TestMemStats(t *testing.T) { // Buffers: 771, // Cached: 4312, // Shared: 2142, + CommitLimit: 1, + CommittedAS: 118680, + Dirty: 4, + HighFree: 0, + HighTotal: 0, + HugePageSize: 4096, + HugePagesFree: 0, + HugePagesTotal: 0, + LowFree: 69936, + LowTotal: 255908, + Mapped: 42236, + PageTables: 1236, + Shared: 0, + SwapCached: 0, + SwapFree: 524280, + SwapTotal: 524280, + VMallocChunk: 3872908, + VMallocTotal: 3874808, + VMallocUsed: 1416, + Writeback: 0, + WritebackTmp: 0, } mps.On("VMStat").Return(vms, nil) @@ -47,6 +68,27 @@ func TestMemStats(t *testing.T) { "inactive": uint64(1124), "wired": uint64(134), "slab": uint64(1234), + "commit_limit": uint64(1), + "committed_as": uint64(118680), + "dirty": uint64(4), + "high_free": uint64(0), + "high_total": uint64(0), + "huge_page_size": uint64(4096), + "huge_pages_free": uint64(0), + "huge_pages_total": uint64(0), + "low_free": uint64(69936), + "low_total": uint64(255908), + "mapped": uint64(42236), + "page_tables": uint64(1236), + "shared": uint64(0), + "swap_cached": uint64(0), + "swap_free": uint64(524280), + "swap_total": uint64(524280), + "vmalloc_chunk": uint64(3872908), + "vmalloc_total": uint64(3874808), + "vmalloc_used": uint64(1416), + "write_back": uint64(0), + "write_back_tmp": uint64(0), } acc.AssertContainsTaggedFields(t, "mem", memfields, make(map[string]string))