diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc index 81ef4cfeebd..f435a5825bf 100644 --- a/CHANGELOG.asciidoc +++ b/CHANGELOG.asciidoc @@ -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* diff --git a/topbeat/beat/sigar.go b/topbeat/beat/sigar.go index ca48e4e4739..00c7265baa7 100644 --- a/topbeat/beat/sigar.go +++ b/topbeat/beat/sigar.go @@ -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 { @@ -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) } diff --git a/topbeat/beat/topbeat.go b/topbeat/beat/topbeat.go index efe721ae4df..e500ce31650 100644 --- a/topbeat/beat/topbeat.go +++ b/topbeat/beat/topbeat.go @@ -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) } } diff --git a/topbeat/beat/topbeat_test.go b/topbeat/beat/topbeat_test.go index 2d13931e757..414e11c09e6 100644 --- a/topbeat/beat/topbeat_test.go +++ b/topbeat/beat/topbeat_test.go @@ -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) } diff --git a/topbeat/docs/fields.asciidoc b/topbeat/docs/fields.asciidoc index e9cb547e0c4..7aea569130d 100644 --- a/topbeat/docs/fields.asciidoc +++ b/topbeat/docs/fields.asciidoc @@ -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 diff --git a/topbeat/etc/fields.yml b/topbeat/etc/fields.yml index 7a40ea2c1ee..0ec3445fb1a 100644 --- a/topbeat/etc/fields.yml +++ b/topbeat/etc/fields.yml @@ -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 @@ -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 diff --git a/topbeat/tests/system/test_procs.py b/topbeat/tests/system/test_procs.py index c6603247d46..3ac4a407079 100644 --- a/topbeat/tests/system/test_procs.py +++ b/topbeat/tests/system/test_procs.py @@ -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]