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

Replace proc.cpu.user_p with proc.cpu.total_p #641

Merged
merged 1 commit into from
Jan 6, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ https://github.com/elastic/beats/compare/1.0.0...master[Check the HEAD diff]
*Packetbeat*

*Topbeat*
- Rename proc.cpu.user_p with proc.cpu.total_p as includes CPU time spent in kernel space {pull}631[631]

*Filebeat*

Expand Down
12 changes: 6 additions & 6 deletions topbeat/beat/sigar.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ type ProcMemStat struct {
}

type ProcCpuTime struct {
User uint64 `json:"user"`
UserPercent float64 `json:"user_p"`
System uint64 `json:"system"`
Total uint64 `json:"total"`
Start string `json:"start_time"`
User uint64 `json:"user"`
System uint64 `json:"system"`
Total uint64 `json:"total"`
TotalPercent float64 `json:"total_p"`
Start string `json:"start_time"`
}

type Process struct {
Expand Down Expand Up @@ -99,7 +99,7 @@ func (m *ProcMemStat) String() string {
}

func (t *ProcCpuTime) String() string {
return fmt.Sprintf("started at %s, %d total %.2f%%CPU, %d us, %d sys", t.Start, t.Total, t.UserPercent, t.User, t.System)
return fmt.Sprintf("started at %s, %d total %.2f%%CPU, %d us, %d sys", t.Start, t.Total, t.TotalPercent, t.User, t.System)

}

Expand Down
2 changes: 1 addition & 1 deletion topbeat/beat/topbeat.go
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ func (t *Topbeat) addProcCpuPercentage(proc *Process) {

t.procsMap[proc.Pid] = proc

proc.Cpu.UserPercent = Round(perc, .5, 2)
proc.Cpu.TotalPercent = Round(perc, .5, 4)

}
}
Expand Down
2 changes: 1 addition & 1 deletion topbeat/beat/topbeat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,5 +146,5 @@ func TestProcCpuPercentage(t *testing.T) {
beat.procsMap[p1.Pid] = &p1

beat.addProcCpuPercentage(&p2)
assert.Equal(t, p2.Cpu.UserPercent, 3.46)
assert.Equal(t, p2.Cpu.TotalPercent, 3.459)
}
4 changes: 2 additions & 2 deletions topbeat/docs/fields.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,11 @@ type: int
The amount of CPU time the process spent in user space.


==== proc.cpu.user_p
==== proc.cpu.total_p

type: float

The percentage of CPU time the process spent in user space.
The percentage of CPU time spent by the process since the last update. Its value is similar with the %CPU value of the process displayed by the top command on unix systems.


==== proc.cpu.system
Expand Down
22 changes: 19 additions & 3 deletions topbeat/etc/fields.yml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,21 @@ system:
type: float
description: >
The percentage of used swap memory.
- name: actual_used
path: swap.actual_used
type: int
description: >
Actual used swap memory. Available only on Unix.
- name: actual_free
path: swap.actual_free
type: int
description: >
Actual available swap memory. Available only on Unix.
- name: actual_used_p
path: swap.actual_used_p
type: float
description: >
The percentage of actual used swap memory.

process:
type: group
Expand Down Expand Up @@ -333,11 +348,12 @@ process:
description: >
The amount of CPU time the process spent in user space.

- name: user_p
path: proc.cpu.user_p
- name: total_p
path: proc.cpu.total_p
type: float
description: >
The percentage of CPU time the process spent in user space.
The percentage of CPU time spent by the process since the last update. Its value is similar with the
%CPU value of the process displayed by the top command on unix systems.

- name: system
path: proc.cpu.system
Expand Down
2 changes: 1 addition & 1 deletion topbeat/tests/system/test_procs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_procs(self):
assert type(output[key]) is int

for key in [
"proc.cpu.user_p",
"proc.cpu.total_p",
"proc.mem.rss_p",
]:
assert type(output[key]) in [int, float]