Skip to content

Commit

Permalink
Fix the CPU values returned for each core (#1863)
Browse files Browse the repository at this point in the history
* Update changelog
  • Loading branch information
monicasarbu authored and ruflin committed Jun 15, 2016
1 parent cd05dc7 commit 28abc38
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
33 changes: 17 additions & 16 deletions metricbeat/module/system/core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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
Expand Down

0 comments on commit 28abc38

Please sign in to comment.