From aa15e7916e3c705fbde0d42857d30c04363b1b32 Mon Sep 17 00:00:00 2001 From: Cameron Sparr Date: Wed, 9 Mar 2016 22:55:26 +0100 Subject: [PATCH] processes: Fix zombie process procfs panic fixes #822 --- plugins/inputs/system/processes.go | 4 ++-- plugins/inputs/system/processes_test.go | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/plugins/inputs/system/processes.go b/plugins/inputs/system/processes.go index b7ee32066..aae0e6ba4 100644 --- a/plugins/inputs/system/processes.go +++ b/plugins/inputs/system/processes.go @@ -65,7 +65,7 @@ func (p *Processes) Gather(acc telegraf.Accumulator) error { func getEmptyFields() map[string]interface{} { fields := map[string]interface{}{ "blocked": int64(0), - "zombie": int64(0), + "zombies": int64(0), "stopped": int64(0), "running": int64(0), "sleeping": int64(0), @@ -105,7 +105,7 @@ func (p *Processes) gatherFromPS(fields map[string]interface{}) error { // Also known as uninterruptible sleep or disk sleep fields["blocked"] = fields["blocked"].(int64) + int64(1) case 'Z': - fields["zombie"] = fields["zombie"].(int64) + int64(1) + fields["zombies"] = fields["zombies"].(int64) + int64(1) case 'T': fields["stopped"] = fields["stopped"].(int64) + int64(1) case 'R': diff --git a/plugins/inputs/system/processes_test.go b/plugins/inputs/system/processes_test.go index 0e2b5e105..de9b6aa5b 100644 --- a/plugins/inputs/system/processes_test.go +++ b/plugins/inputs/system/processes_test.go @@ -40,10 +40,11 @@ func TestFromPS(t *testing.T) { require.NoError(t, err) fields := getEmptyFields() - fields["blocked"] = int64(1) + fields["blocked"] = int64(4) + fields["zombies"] = int64(1) fields["running"] = int64(4) fields["sleeping"] = int64(34) - fields["total"] = int64(39) + fields["total"] = int64(43) acc.AssertContainsTaggedFields(t, "processes", fields, map[string]string{}) } @@ -139,6 +140,10 @@ S S+ S+ Ss +L +U +Z +D S+ `