From 28abc38f4e5f324c6bbf2d7735f990fafb6a6ffc Mon Sep 17 00:00:00 2001 From: Monica Sarbu Date: Wed, 15 Jun 2016 15:38:30 +0200 Subject: [PATCH] Fix the CPU values returned for each core (#1863) * Update changelog --- CHANGELOG.asciidoc | 1 + metricbeat/module/system/core/core.go | 33 ++++++++++++++------------- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 95ed596cc90..995209dde08 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -34,6 +34,7 @@ https://github.com/elastic/beats/compare/v5.0.0-alpha3...master[Check the HEAD d - Fix beats load balancer deadlock if max_retries: -1 or publish_async is enabled in filebeat. {issue}1829[1829] *Metricbeat* +- Fix the CPU values returned for each core. {issue}1863[1863] *Packetbeat* - Add missing nil-check to memcached GapInStream handler. {issue}1162[1162] diff --git a/metricbeat/module/system/core/core.go b/metricbeat/module/system/core/core.go index 7cfc37caeb3..f0a289709ff 100644 --- a/metricbeat/module/system/core/core.go +++ b/metricbeat/module/system/core/core.go @@ -51,6 +51,7 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) { if err != nil { return nil, errors.Wrap(err, "cpu core times") } + m.cpu.AddCpuPercentageList(cpuCoreStat) cores := []common.MapStr{} @@ -59,40 +60,40 @@ func (m *MetricSet) Fetch() ([]common.MapStr, error) { coreStat := common.MapStr{ "user": common.MapStr{ - "pct": &stat.UserPercent, + "pct": stat.UserPercent, }, "system": common.MapStr{ - "pct": &stat.SystemPercent, + "pct": stat.SystemPercent, }, "idle": common.MapStr{ - "pct": &stat.IdlePercent, + "pct": stat.IdlePercent, }, "iowait": common.MapStr{ - "pct": &stat.IOwaitPercent, + "pct": stat.IOwaitPercent, }, "irq": common.MapStr{ - "pct": &stat.IrqPercent, + "pct": stat.IrqPercent, }, "nice": common.MapStr{ - "pct": &stat.NicePercent, + "pct": stat.NicePercent, }, "softirq": common.MapStr{ - "pct": &stat.SoftIrqPercent, + "pct": stat.SoftIrqPercent, }, "steal": common.MapStr{ - "pct": &stat.StealPercent, + "pct": stat.StealPercent, }, } if m.cpu.CpuTicks { - coreStat["user"].(common.MapStr)["ticks"] = &stat.User - coreStat["system"].(common.MapStr)["ticks"] = &stat.Sys - coreStat["nice"].(common.MapStr)["ticks"] = &stat.Nice - coreStat["idle"].(common.MapStr)["ticks"] = &stat.Idle - coreStat["iowait"].(common.MapStr)["ticks"] = &stat.Wait - coreStat["irq"].(common.MapStr)["ticks"] = &stat.Irq - coreStat["softirq"].(common.MapStr)["ticks"] = &stat.SoftIrq - coreStat["steal"].(common.MapStr)["ticks"] = &stat.Stolen + coreStat["user"].(common.MapStr)["ticks"] = stat.User + coreStat["system"].(common.MapStr)["ticks"] = stat.Sys + coreStat["nice"].(common.MapStr)["ticks"] = stat.Nice + coreStat["idle"].(common.MapStr)["ticks"] = stat.Idle + coreStat["iowait"].(common.MapStr)["ticks"] = stat.Wait + coreStat["irq"].(common.MapStr)["ticks"] = stat.Irq + coreStat["softirq"].(common.MapStr)["ticks"] = stat.SoftIrq + coreStat["steal"].(common.MapStr)["ticks"] = stat.Stolen } coreStat["id"] = core