From 13f314a5076a47b208aeef5bdab12470837e26c1 Mon Sep 17 00:00:00 2001 From: jeremydenoun Date: Thu, 9 Mar 2017 20:28:54 +0100 Subject: [PATCH] Report DEAD (X) State Process (#2501) Report count of processes in dead (X) process state from the processes input. This process state is only valid on Linux. --- CHANGELOG.md | 1 + plugins/inputs/system/PROCESSES_README.md | 4 +++- plugins/inputs/system/processes.go | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6053bd66..a11752b5c 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 diff --git a/plugins/inputs/system/PROCESSES_README.md b/plugins/inputs/system/PROCESSES_README.md index 006e043fb..aaeb279f8 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 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) @@ -54,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 ``` diff --git a/plugins/inputs/system/processes.go b/plugins/inputs/system/processes.go index 0950323fd..202bdf058 100644 --- a/plugins/inputs/system/processes.go +++ b/plugins/inputs/system/processes.go @@ -81,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) } @@ -107,6 +108,8 @@ func (p *Processes) gatherFromPS(fields map[string]interface{}) error { fields["blocked"] = fields["blocked"].(int64) + int64(1) 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': @@ -164,6 +167,8 @@ func (p *Processes) gatherFromProc(fields map[string]interface{}) error { fields["blocked"] = fields["blocked"].(int64) + int64(1) 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':