From be64e4fa34c4ef7907a76ea04b125207b59ff5cd Mon Sep 17 00:00:00 2001 From: Sangbum Kim Date: Mon, 9 Jul 2018 04:59:34 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AA=87=EA=B0=80=EC=A7=80=20=EC=98=A4?= =?UTF-8?q?=ED=83=80=20=EB=8D=94=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- producer/os_darwin.go | 15 +++++++++++++++ producer/os_linux.go | 23 +++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/producer/os_darwin.go b/producer/os_darwin.go index 12a56ce..82caf22 100644 --- a/producer/os_darwin.go +++ b/producer/os_darwin.go @@ -66,6 +66,9 @@ func (p *osMetric) readMemoryStat(info *OSMetricInfo, errChan chan<- error, wait } }() + if err !=nil{ + return + } p.logger.Debugf("memory total: ", misc.FileSizeIEC(memoryInfo.Total)) p.logger.Debugf("memory active: ", misc.FileSizeIEC(memoryInfo.Active)) p.logger.Debugf("memory cached: ", misc.FileSizeIEC(memoryInfo.Cached)) @@ -102,6 +105,9 @@ func (p *osMetric) readLoadStat(info *OSMetricInfo, errChan chan<- error, waiter } }() + if err !=nil{ + return + } p.logger.Debugf("load Loadavg1: %f \n", load.Loadavg1) p.logger.Debugf("load Loadavg5: %f \n", load.Loadavg5) p.logger.Debugf("load Loadavg15: %f \n", load.Loadavg15) @@ -126,6 +132,9 @@ func (p *osMetric) readNetworkStat(info *OSMetricInfo, errChan chan<- error, wai } }() + if err !=nil{ + return + } netIoMap := make(map[string]NetIOInfo) for _, netio := range netios { p.logger.Debugf("netio name: ", netio.Name) @@ -155,6 +164,9 @@ func (p *osMetric) readUptimeStat(info *OSMetricInfo, errChan chan<- error, wait } }() + if err !=nil{ + return + } p.logger.Debugf("readUptimeStat: %s\n", durafmt.Parse(ut).String()) info.Uptime = ut @@ -175,6 +187,9 @@ func (p *osMetric) readCpuStat(info *OSMetricInfo, errChan chan<- error, waiter } }() + if err !=nil{ + return + } p.logger.Debugf("readCpuStat: idle=%d\n", ct.Idle) p.logger.Debugf("readCpuStat: nice=%d\n", ct.Nice) p.logger.Debugf("readCpuStat: system=%d\n", ct.System) diff --git a/producer/os_linux.go b/producer/os_linux.go index 1fb91c1..5cb49bd 100644 --- a/producer/os_linux.go +++ b/producer/os_linux.go @@ -12,6 +12,7 @@ import ( "amuz.es/src/infra/goutils/misc" "time" "go.uber.org/multierr" + "sync" ) type NetIOInfo struct { @@ -61,7 +62,7 @@ type OSMetricInfo struct { Uptime time.Duration CPU CPUInfo - DiskIO DiskIOInfo + DiskIO map[string]DiskIOInfo At time.Time } @@ -79,6 +80,9 @@ func (p *osMetric) readMemoryStat(info *OSMetricInfo, errChan chan<- error, wait } }() + if err !=nil{ + return + } p.logger.Debugf("memory total: ", misc.FileSizeIEC(memoryInfo.Total)) p.logger.Debugf("memory used: ", misc.FileSizeIEC(memoryInfo.Used)) p.logger.Debugf("memory buffers: ", misc.FileSizeIEC(memoryInfo.Buffers)) @@ -118,6 +122,9 @@ func (p *osMetric) readLoadStat(info *OSMetricInfo, errChan chan<- error, waiter } }() + if err !=nil{ + return + } p.logger.Debugf("load Loadavg1: %f \n", load.Loadavg1) p.logger.Debugf("load Loadavg5: %f \n", load.Loadavg5) p.logger.Debugf("load Loadavg15: %f \n", load.Loadavg15) @@ -142,6 +149,9 @@ func (p *osMetric) readNetworkStat(info *OSMetricInfo, errChan chan<- error, wai } }() + if err !=nil{ + return + } netIoMap := make(map[string]NetIOInfo) for _, netio := range netios { p.logger.Debugf("netio name: ", netio.Name) @@ -171,6 +181,9 @@ func (p *osMetric) readUptimeStat(info *OSMetricInfo, errChan chan<- error, wait } }() + if err !=nil{ + return + } p.logger.Debugf("readUptimeStat: %s\n", durafmt.Parse(ut).String()) info.Uptime = ut @@ -191,6 +204,9 @@ func (p *osMetric) readCpuStat(info *OSMetricInfo, errChan chan<- error, waiter } }() + if err !=nil{ + return + } p.logger.Debugf("cpu user: %d\n", ct.User) p.logger.Debugf("cpu nice: %d\n", ct.Nice) p.logger.Debugf("cpu system: %d\n", ct.System) @@ -234,6 +250,9 @@ func (p *osMetric) readDiskStat(info *OSMetricInfo, errChan chan<- error, waiter errChan <- err } }() + if err !=nil{ + return + } diskIoMap := make(map[string]DiskIOInfo) for _, dsk := range diskinfos { @@ -241,7 +260,7 @@ func (p *osMetric) readDiskStat(info *OSMetricInfo, errChan chan<- error, waiter p.logger.Debugf("disk read: ", misc.FileSizeIEC(dsk.ReadsCompleted)) p.logger.Debugf("disk written: ", misc.FileSizeIEC(dsk.WritesCompleted)) diskIoMap[dsk.Name] = DiskIOInfo{ - Name: netio.Name, + Name: dsk.Name, ReadsCompletedBytes: dsk.ReadsCompleted, WritesCompletedBytes: dsk.WritesCompleted, }