From 84a1cc5a63e1bf48bb024dee091d4944937c575a Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Tue, 10 Jul 2018 01:44:28 +0900 Subject: [PATCH] =?UTF-8?q?linux=20Available=20memory=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- producer/os_linux.go | 4 ++++ test/os_linux.go | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/producer/os_linux.go b/producer/os_linux.go index 81ab794..8dbdd0d 100644 --- a/producer/os_linux.go +++ b/producer/os_linux.go @@ -29,6 +29,7 @@ type DiskIOInfo struct { } type MemoryInfo struct { Total uint64 `json:"total_bytes"` + Available uint64 `json:"available_bytes"` Used uint64 `json:"used_bytes"` Buffers uint64 `json:"buffers_bytes"` Cached uint64 `json:"cached_bytes"` @@ -172,6 +173,7 @@ func (p *OSMetricInfo) MarshalMemory() (name string, tags []map[string]string, f { "total_bytes": p.Memory.Total, "used_bytes": p.Memory.Used, + "available_bytes": p.Memory.Available, "buffers_bytes": p.Memory.Buffers, "cached_bytes": p.Memory.Cached, "free_bytes": p.Memory.Free, @@ -216,6 +218,7 @@ func (p *osMetric) readMemoryStat(info *OSMetricInfo, errChan chan<- error, wait } p.logger.Debugf("memory total: ", misc.FileSizeIEC(memoryInfo.Total)) p.logger.Debugf("memory used: ", misc.FileSizeIEC(memoryInfo.Used)) + p.logger.Debugf("memory available: ", misc.FileSizeIEC(memoryInfo.Available)) p.logger.Debugf("memory buffers: ", misc.FileSizeIEC(memoryInfo.Buffers)) p.logger.Debugf("memory cached: ", misc.FileSizeIEC(memoryInfo.Cached)) p.logger.Debugf("memory free: ", misc.FileSizeIEC(memoryInfo.Free)) @@ -228,6 +231,7 @@ func (p *osMetric) readMemoryStat(info *OSMetricInfo, errChan chan<- error, wait info.Memory.Total = memoryInfo.Total info.Memory.Used = memoryInfo.Used + info.Memory.Available = memoryInfo.Available info.Memory.Buffers = memoryInfo.Buffers info.Memory.Cached = memoryInfo.Cached info.Memory.Free = memoryInfo.Free diff --git a/test/os_linux.go b/test/os_linux.go index 2d59807..7ee42c5 100644 --- a/test/os_linux.go +++ b/test/os_linux.go @@ -33,11 +33,6 @@ func a() { //SwapFree uint64 // Stats represents memory statistics for linux - type Stats struct { - Total, Used, Buffers, Cached, Free, Available, Active, Inactive, - SwapTotal, SwapUsed, SwapCached, SwapFree uint64 - MemAvailableEnabled bool - } fmt.Println("memory total: ", misc.FileSizeIEC(memory.Total)) fmt.Println("memory used: ", misc.FileSizeIEC(memory.Used)) fmt.Println("memory buffers: ", misc.FileSizeIEC(memory.Buffers))