Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Cpu.Get() on Windows to not use floating point artimetic #1128

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Expand Up @@ -51,6 +51,7 @@ https://github.com/elastic/beats/compare/v1.1.0...master[Check the HEAD diff]
- Check column length in pgsql parser. {issue}565{565

*Topbeat*
- Fix issue with cpu.system_p being abnormally high {pull}1200[1200]

*Filebeat*
- Stop filebeat if filebeat is started without any prospectors defined or empty prospectors {pull}644[644] {pull}647[647]
Expand Down
6 changes: 3 additions & 3 deletions topbeat/beater/topbeat.go
Expand Up @@ -436,9 +436,9 @@ func (t *Topbeat) addCpuPercentage(t2 *CpuTimes) {
calculate := func(field2 uint64, field1 uint64) float64 {

perc := 0.0
delta := field2 - field1
delta := int64(field2 - field1)
perc = float64(delta) / float64(all_delta)
return Round(perc, .5, 2)
return Round(perc, .5, 4)
}

t2.UserPercent = calculate(t2.Cpu.User, t1.Cpu.User)
Expand All @@ -460,7 +460,7 @@ func (t *Topbeat) addCpuPercentageList(t2 []CpuTimes) {
perc := 0.0
delta := field2 - field1
perc = float64(delta) / float64(all_delta)
return Round(perc, .5, 2)
return Round(perc, .5, 4)
}

for i := 0; i < len(t1); i++ {
Expand Down
4 changes: 2 additions & 2 deletions topbeat/beater/topbeat_test.go
Expand Up @@ -104,8 +104,8 @@ func TestCpuPercentage(t *testing.T) {

beat.addCpuPercentage(&cpu2)

assert.Equal(t, cpu2.UserPercent, 0.95)
assert.Equal(t, cpu2.SystemPercent, 0.04)
assert.Equal(t, cpu2.UserPercent, 0.9502)
assert.Equal(t, cpu2.SystemPercent, 0.0448)
}

func TestProcMemPercentage(t *testing.T) {
Expand Down
20 changes: 16 additions & 4 deletions vendor/github.com/elastic/gosigar/.appveyor.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 33 additions & 1 deletion vendor/github.com/elastic/gosigar/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions vendor/github.com/elastic/gosigar/.travis.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions vendor/github.com/elastic/gosigar/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/elastic/gosigar/concrete_sigar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

147 changes: 69 additions & 78 deletions vendor/github.com/elastic/gosigar/concrete_sigar_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.