Skip to content

Commit

Permalink
Merge pull request #1128 from andrewkroh/feature/topbeat-windows-cpu-get
Browse files Browse the repository at this point in the history
Change Cpu.Get() on Windows to not use floating point artimetic
  • Loading branch information
monicasarbu committed Mar 8, 2016
2 parents 2006e79 + 71bd823 commit 3ccb42d
Show file tree
Hide file tree
Showing 28 changed files with 587 additions and 612 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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.

Loading

0 comments on commit 3ccb42d

Please sign in to comment.