From 6a5d8e31b38932d1e79e5762c3118a18477fbbda Mon Sep 17 00:00:00 2001 From: Ted Zlatanov Date: Mon, 11 Dec 2017 18:31:52 -0500 Subject: [PATCH] Support I (idle) process state on procfs+Linux (#3530) --- plugins/inputs/system/PROCESSES_README.md | 4 ++-- plugins/inputs/system/processes.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/plugins/inputs/system/PROCESSES_README.md b/plugins/inputs/system/PROCESSES_README.md index 508e1fa81..3c2e27291 100644 --- a/plugins/inputs/system/PROCESSES_README.md +++ b/plugins/inputs/system/PROCESSES_README.md @@ -30,7 +30,7 @@ Using the environment variable `HOST_PROC` the plugin will retrieve process info - zombie - dead - wait (freebsd only) - - idle (bsd only) + - idle (bsd and Linux 4+ only) - paging (linux only) - total_threads (linux only) @@ -47,7 +47,7 @@ Linux FreeBSD Darwin meaning Z Z Z zombie X none none dead T T T stopped - none I I idle (sleeping for longer than about 20 seconds) + I I I idle (sleeping for longer than about 20 seconds) D D,L U blocked (waiting in uninterruptible sleep, or locked) W W none paging (linux kernel < 2.6 only), wait (freebsd) ``` diff --git a/plugins/inputs/system/processes.go b/plugins/inputs/system/processes.go index 1ceb4fb2d..9258bc417 100644 --- a/plugins/inputs/system/processes.go +++ b/plugins/inputs/system/processes.go @@ -85,6 +85,7 @@ func getEmptyFields() map[string]interface{} { fields["dead"] = int64(0) fields["paging"] = int64(0) fields["total_threads"] = int64(0) + fields["idle"] = int64(0) } return fields } @@ -174,6 +175,8 @@ func (p *Processes) gatherFromProc(fields map[string]interface{}) error { fields["stopped"] = fields["stopped"].(int64) + int64(1) case 'W': fields["paging"] = fields["paging"].(int64) + int64(1) + case 'I': + fields["idle"] = fields["idle"].(int64) + int64(1) default: log.Printf("I! processes: Unknown state [ %s ] in file %s", string(stats[0][0]), filename)