From d90026646f70d7be383baa822eecaab4bae48c6e Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Thu, 9 Jul 2015 20:06:30 +0200 Subject: [PATCH] Implement process stats. --- plugins/elasticsearch/elasticsearch.go | 4 +++ plugins/elasticsearch/elasticsearch_test.go | 4 +++ plugins/elasticsearch/testdata_test.go | 27 +++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/plugins/elasticsearch/elasticsearch.go b/plugins/elasticsearch/elasticsearch.go index fc0f6e6fb..8270ee702 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/elasticsearch/elasticsearch.go @@ -17,6 +17,7 @@ type node struct { Attributes map[string]string `json:"attributes"` Indices interface{} `json:"indices"` Os interface{} `json:"os"` + Process interface{} `json:"process"` } const sampleConfig = ` @@ -103,6 +104,9 @@ func (e *Elasticsearch) gatherUrl(url string, acc plugins.Accumulator) error { if err := e.parseInterface(acc, "os", tags, n.Os); err != nil { return err } + if err := e.parseInterface(acc, "process", tags, n.Process); err != nil { + return err + } } return nil diff --git a/plugins/elasticsearch/elasticsearch_test.go b/plugins/elasticsearch/elasticsearch_test.go index 8bd5d56ca..b187cc3d4 100644 --- a/plugins/elasticsearch/elasticsearch_test.go +++ b/plugins/elasticsearch/elasticsearch_test.go @@ -58,4 +58,8 @@ func TestElasticsearch(t *testing.T) { for key, val := range osExpected { assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) } + + for key, val := range processExpected { + assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) + } } diff --git a/plugins/elasticsearch/testdata_test.go b/plugins/elasticsearch/testdata_test.go index 750636428..fc9dc0f0b 100644 --- a/plugins/elasticsearch/testdata_test.go +++ b/plugins/elasticsearch/testdata_test.go @@ -154,6 +154,21 @@ const statsResponse = ` "used_in_bytes": 0, "free_in_bytes": 487997440 } + }, + "process": { + "timestamp": 1436460392945, + "open_file_descriptors": 160, + "cpu": { + "percent": 2, + "sys_in_millis": 1870, + "user_in_millis": 13610, + "total_in_millis": 15480 + }, + "mem": { + "resident_in_bytes": 246382592, + "share_in_bytes": 18747392, + "total_virtual_in_bytes": 4747890688 + } } } } @@ -249,3 +264,15 @@ var osExpected = map[string]float64{ "os_mem_free_in_bytes": 477761536, "os_mem_used_in_bytes": 1621868544, } + +var processExpected = map[string]float64{ + "process_mem_resident_in_bytes": 246382592, + "process_mem_share_in_bytes": 18747392, + "process_mem_total_virtual_in_bytes": 4747890688, + "process_timestamp": 1436460392945, + "process_open_file_descriptors": 160, + "process_cpu_total_in_millis": 15480, + "process_cpu_percent": 2, + "process_cpu_sys_in_millis": 1870, + "process_cpu_user_in_millis": 13610, +}