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

Follow up on comments from #4231 #4305

Merged
merged 1 commit into from
May 13, 2017
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
12 changes: 6 additions & 6 deletions metricbeat/module/system/process_summary/process_summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ func (m *MetricSet) Fetch() (common.MapStr, error) {

switch byte(state.State) {
case 'S':
summary.sleeping += 1
summary.sleeping++
case 'R':
summary.running += 1
summary.running++
case 'D':
summary.idle += 1
summary.idle++
case 'T':
summary.stopped += 1
summary.stopped++
case 'Z':
summary.zombie += 1
summary.zombie++
default:
logp.Err("Unknown state <%v> for process with pid %d", state.State, pid)
summary.unknown += 1
summary.unknown++
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ func TestFetch(t *testing.T) {
f := mbtest.NewEventFetcher(t, getConfig())
event, err := f.Fetch()
assert.NoError(t, err)
assert.Contains(t, event, "total")
assert.Contains(t, event, "sleeping")
assert.Contains(t, event, "running")
assert.Contains(t, event, "idle")
assert.Contains(t, event, "stopped")
assert.Contains(t, event, "zombie")
assert.Contains(t, event, "unknown")

total := event["sleeping"].(int) + event["running"].(int) + event["idle"].(int) +
event["stopped"].(int) + event["zombie"].(int) + event["unknown"].(int)

assert.Equal(t, event["total"].(int), total)
}

func getConfig() map[string]interface{} {
Expand Down
4 changes: 4 additions & 0 deletions metricbeat/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,17 @@ def test_process_summary(self):
self.assert_fields_are_documented(evt)

summary = evt["system"]["process"]["summary"]
assert isinstance(summary["total"], int)
assert isinstance(summary["sleeping"], int)
assert isinstance(summary["running"], int)
assert isinstance(summary["idle"], int)
assert isinstance(summary["stopped"], int)
assert isinstance(summary["zombie"], int)
assert isinstance(summary["unknown"], int)

assert summary["total"] == summary["sleeping"] + summary["running"] + \
summary["idle"] + summary["stopped"] + summary["zombie"] + summary["unknown"]

@unittest.skipUnless(re.match("(?i)win|linux|darwin|freebsd", sys.platform), "os")
def test_process(self):
"""
Expand Down