From f9c65cded5a8d0187b2dcecd203e884be5f41626 Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Tue, 7 Mar 2017 17:27:05 +0100 Subject: [PATCH 1/8] DEAD State Process Following https://github.com/torvalds/linux/blob/master/fs/proc/array.c#L126 telegraf plugin should handle DEAD state process and possibility to see it (http://unix.stackexchange.com/questions/126101/possible-to-see-dead-proccesses) specially in Docker context, the X state should be handle (I think this should be process like zombies but if you consider another metrics is necessary I can add it to interface) --- plugins/inputs/system/processes.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/system/processes.go b/plugins/inputs/system/processes.go index 0950323fde8db..b9d87a833b320 100644 --- a/plugins/inputs/system/processes.go +++ b/plugins/inputs/system/processes.go @@ -105,7 +105,7 @@ func (p *Processes) gatherFromPS(fields map[string]interface{}) error { case 'U', 'D', 'L': // Also known as uninterruptible sleep or disk sleep fields["blocked"] = fields["blocked"].(int64) + int64(1) - case 'Z': + case 'Z', 'X': fields["zombies"] = fields["zombies"].(int64) + int64(1) case 'T': fields["stopped"] = fields["stopped"].(int64) + int64(1) @@ -162,7 +162,7 @@ func (p *Processes) gatherFromProc(fields map[string]interface{}) error { fields["sleeping"] = fields["sleeping"].(int64) + int64(1) case 'D': fields["blocked"] = fields["blocked"].(int64) + int64(1) - case 'Z': + case 'Z','X': fields["zombies"] = fields["zombies"].(int64) + int64(1) case 'T', 't': fields["stopped"] = fields["stopped"].(int64) + int64(1) From 97e8f3532b34242b996f268767b8a095a6919784 Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Tue, 7 Mar 2017 17:36:44 +0100 Subject: [PATCH 2/8] Update processes.go --- plugins/inputs/system/processes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/system/processes.go b/plugins/inputs/system/processes.go index b9d87a833b320..2d4e7797f7568 100644 --- a/plugins/inputs/system/processes.go +++ b/plugins/inputs/system/processes.go @@ -162,7 +162,7 @@ func (p *Processes) gatherFromProc(fields map[string]interface{}) error { fields["sleeping"] = fields["sleeping"].(int64) + int64(1) case 'D': fields["blocked"] = fields["blocked"].(int64) + int64(1) - case 'Z','X': + case 'Z', 'X': fields["zombies"] = fields["zombies"].(int64) + int64(1) case 'T', 't': fields["stopped"] = fields["stopped"].(int64) + int64(1) From 2631e05f4bdbc06dfcf0c22f4c4603cb2a4a990f Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Wed, 8 Mar 2017 19:23:29 +0100 Subject: [PATCH 3/8] Update CHANGELOG.md add reference in change log to issue/pr --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5773179b6c29d..2786266ea5df3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ be deprecated eventually. - [#2339](https://github.com/influxdata/telegraf/pull/2339): Increment gather_errors for all errors emitted by inputs. - [#2071](https://github.com/influxdata/telegraf/issues/2071): Use official docker SDK. - [#1678](https://github.com/influxdata/telegraf/pull/1678): Add AMQP consumer input plugin +- [#2501](https://github.com/influxdata/telegraf/pull/2501): Support DEAD(X) state in system input plugin. ### Bugfixes From ccc75aadfd91daf3d891f4a25ef843eb1be54b0b Mon Sep 17 00:00:00 2001 From: Jeremy Denoun Date: Wed, 8 Mar 2017 21:41:18 +0000 Subject: [PATCH 4/8] dead counter independent --- plugins/inputs/system/processes.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/system/processes.go b/plugins/inputs/system/processes.go index 2d4e7797f7568..25b697de180fb 100644 --- a/plugins/inputs/system/processes.go +++ b/plugins/inputs/system/processes.go @@ -66,6 +66,7 @@ func getEmptyFields() map[string]interface{} { fields := map[string]interface{}{ "blocked": int64(0), "zombies": int64(0), + "dead": int64(0), "stopped": int64(0), "running": int64(0), "sleeping": int64(0), @@ -105,8 +106,10 @@ func (p *Processes) gatherFromPS(fields map[string]interface{}) error { case 'U', 'D', 'L': // Also known as uninterruptible sleep or disk sleep fields["blocked"] = fields["blocked"].(int64) + int64(1) - case 'Z', 'X': + case 'Z': fields["zombies"] = fields["zombies"].(int64) + int64(1) + case 'X': + fields["dead"] = fields["dead"].(int64) + int64(1) case 'T': fields["stopped"] = fields["stopped"].(int64) + int64(1) case 'R': @@ -162,8 +165,10 @@ func (p *Processes) gatherFromProc(fields map[string]interface{}) error { fields["sleeping"] = fields["sleeping"].(int64) + int64(1) case 'D': fields["blocked"] = fields["blocked"].(int64) + int64(1) - case 'Z', 'X': + case 'Z': fields["zombies"] = fields["zombies"].(int64) + int64(1) + case 'X': + fields["dead"] = fields["dead"].(int64) + int64(1) case 'T', 't': fields["stopped"] = fields["stopped"].(int64) + int64(1) case 'W': From 66bc49eecabb3b7a189fe9177dab7daf9ce9f1b6 Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Thu, 9 Mar 2017 12:20:45 +0100 Subject: [PATCH 5/8] add dead state description --- plugins/inputs/system/PROCESSES_README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/inputs/system/PROCESSES_README.md b/plugins/inputs/system/PROCESSES_README.md index 006e043fb8dda..7627704429914 100644 --- a/plugins/inputs/system/PROCESSES_README.md +++ b/plugins/inputs/system/PROCESSES_README.md @@ -23,6 +23,7 @@ it requires access to execute `ps`. - stopped - total - zombie + - dead - wait (freebsd only) - idle (bsd only) - paging (linux only) @@ -39,6 +40,7 @@ Linux FreeBSD Darwin meaning R R R running S S S sleeping Z Z Z zombie + X X X dead T T T stopped none I I idle (sleeping for longer than about 20 seconds) D D,L U blocked (waiting in uninterruptible sleep, or locked) From 6871e68f9afaf704139fb40450e821c32a628782 Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Thu, 9 Mar 2017 19:45:55 +0100 Subject: [PATCH 6/8] fix on BSD,Darwing No really Dead state on this platform --- plugins/inputs/system/PROCESSES_README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/system/PROCESSES_README.md b/plugins/inputs/system/PROCESSES_README.md index 7627704429914..b56db0f740972 100644 --- a/plugins/inputs/system/PROCESSES_README.md +++ b/plugins/inputs/system/PROCESSES_README.md @@ -40,7 +40,7 @@ Linux FreeBSD Darwin meaning R R R running S S S sleeping Z Z Z zombie - X X X dead + X none none dead T T T stopped none I I idle (sleeping for longer than about 20 seconds) D D,L U blocked (waiting in uninterruptible sleep, or locked) From d2b6b986794ec8058b1922d4701127b151ceb9e7 Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Thu, 9 Mar 2017 19:46:32 +0100 Subject: [PATCH 7/8] fix example --- plugins/inputs/system/PROCESSES_README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/system/PROCESSES_README.md b/plugins/inputs/system/PROCESSES_README.md index b56db0f740972..aaeb279f80647 100644 --- a/plugins/inputs/system/PROCESSES_README.md +++ b/plugins/inputs/system/PROCESSES_README.md @@ -56,5 +56,5 @@ None ``` $ telegraf -config ~/ws/telegraf.conf -input-filter processes -test * Plugin: processes, Collection 1 -> processes blocked=8i,running=1i,sleeping=265i,stopped=0i,total=274i,zombie=0i,paging=0i,total_threads=687i 1457478636980905042 +> processes blocked=8i,running=1i,sleeping=265i,stopped=0i,total=274i,zombie=0i,dead=0i,paging=0i,total_threads=687i 1457478636980905042 ``` From 78859961163c0438f063b56ab49c7f6477875cb3 Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Thu, 9 Mar 2017 20:03:19 +0100 Subject: [PATCH 8/8] dead only for linux --- plugins/inputs/system/processes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/system/processes.go b/plugins/inputs/system/processes.go index 25b697de180fb..202bdf058ddd6 100644 --- a/plugins/inputs/system/processes.go +++ b/plugins/inputs/system/processes.go @@ -66,7 +66,6 @@ func getEmptyFields() map[string]interface{} { fields := map[string]interface{}{ "blocked": int64(0), "zombies": int64(0), - "dead": int64(0), "stopped": int64(0), "running": int64(0), "sleeping": int64(0), @@ -82,6 +81,7 @@ func getEmptyFields() map[string]interface{} { case "openbsd": fields["idle"] = int64(0) case "linux": + fields["dead"] = int64(0) fields["paging"] = int64(0) fields["total_threads"] = int64(0) }