From 4743c9ab16b3c5ef1432b87dc0625c185fc292ee Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Thu, 9 Jul 2015 20:23:04 +0200 Subject: [PATCH] Implement network 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 de1efc767..88fc87a26 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/elasticsearch/elasticsearch.go @@ -20,6 +20,7 @@ type node struct { Process interface{} `json:"process"` JVM interface{} `json:"jvm"` ThreadPool interface{} `json:"thread_pool"` + Network interface{} `json:"network"` } const sampleConfig = ` @@ -115,6 +116,9 @@ func (e *Elasticsearch) gatherUrl(url string, acc plugins.Accumulator) error { if err := e.parseInterface(acc, "thread_pool", tags, n.ThreadPool); err != nil { return err } + if err := e.parseInterface(acc, "network", tags, n.Network); err != nil { + return err + } } return nil diff --git a/plugins/elasticsearch/elasticsearch_test.go b/plugins/elasticsearch/elasticsearch_test.go index e8febf042..5f0623bea 100644 --- a/plugins/elasticsearch/elasticsearch_test.go +++ b/plugins/elasticsearch/elasticsearch_test.go @@ -70,4 +70,8 @@ func TestElasticsearch(t *testing.T) { for key, val := range threadPoolExpected { assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) } + + for key, val := range networkExpected { + assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) + } } diff --git a/plugins/elasticsearch/testdata_test.go b/plugins/elasticsearch/testdata_test.go index 5562c17e8..d887e5fe9 100644 --- a/plugins/elasticsearch/testdata_test.go +++ b/plugins/elasticsearch/testdata_test.go @@ -367,6 +367,20 @@ const statsResponse = ` "largest": 1, "completed": 0 } + }, + "network": { + "tcp": { + "active_opens": 13, + "passive_opens": 16, + "curr_estab": 29, + "in_segs": 113, + "out_segs": 97, + "retrans_segs": 0, + "estab_resets": 0, + "attempt_fails": 0, + "in_errs": 0, + "out_rsts": 0 + } } } } @@ -614,3 +628,16 @@ var threadPoolExpected = map[string]float64{ "thread_pool_flush_largest": 5, "thread_pool_flush_completed": 3, } + +var networkExpected = map[string]float64{ + "network_tcp_in_errs": 0, + "network_tcp_passive_opens": 16, + "network_tcp_curr_estab": 29, + "network_tcp_in_segs": 113, + "network_tcp_out_segs": 97, + "network_tcp_retrans_segs": 0, + "network_tcp_attempt_fails": 0, + "network_tcp_active_opens": 13, + "network_tcp_estab_resets": 0, + "network_tcp_out_rsts": 0, +}