Navigation Menu

Skip to content

Commit

Permalink
Follow up on comments from #4231 (#4305)
Browse files Browse the repository at this point in the history
This addresses comments in #4231 that came just before the PR got merged.
  • Loading branch information
tsg authored and andrewkroh committed May 13, 2017
1 parent dfa1b58 commit 0593f67
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
12 changes: 6 additions & 6 deletions metricbeat/module/system/process_summary/process_summary.go
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
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
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

0 comments on commit 0593f67

Please sign in to comment.