From ec4079733e5be900338ee19fb4e3d45292ca84cb Mon Sep 17 00:00:00 2001 From: Orne Brocaar Date: Thu, 9 Jul 2015 20:32:56 +0200 Subject: [PATCH] Implement fs stats. --- plugins/elasticsearch/elasticsearch.go | 4 ++++ plugins/elasticsearch/elasticsearch_test.go | 4 ++++ plugins/elasticsearch/testdata_test.go | 26 +++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/plugins/elasticsearch/elasticsearch.go b/plugins/elasticsearch/elasticsearch.go index 88fc87a26..2600a583c 100644 --- a/plugins/elasticsearch/elasticsearch.go +++ b/plugins/elasticsearch/elasticsearch.go @@ -21,6 +21,7 @@ type node struct { JVM interface{} `json:"jvm"` ThreadPool interface{} `json:"thread_pool"` Network interface{} `json:"network"` + FS interface{} `json:"fs"` } const sampleConfig = ` @@ -119,6 +120,9 @@ func (e *Elasticsearch) gatherUrl(url string, acc plugins.Accumulator) error { if err := e.parseInterface(acc, "network", tags, n.Network); err != nil { return err } + if err := e.parseInterface(acc, "fs", tags, n.FS); err != nil { + return err + } } return nil diff --git a/plugins/elasticsearch/elasticsearch_test.go b/plugins/elasticsearch/elasticsearch_test.go index 5f0623bea..36bf46ae3 100644 --- a/plugins/elasticsearch/elasticsearch_test.go +++ b/plugins/elasticsearch/elasticsearch_test.go @@ -74,4 +74,8 @@ func TestElasticsearch(t *testing.T) { for key, val := range networkExpected { assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) } + + for key, val := range fsExpected { + assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) + } } diff --git a/plugins/elasticsearch/testdata_test.go b/plugins/elasticsearch/testdata_test.go index d887e5fe9..1d57c7404 100644 --- a/plugins/elasticsearch/testdata_test.go +++ b/plugins/elasticsearch/testdata_test.go @@ -381,6 +381,25 @@ const statsResponse = ` "in_errs": 0, "out_rsts": 0 } + }, + "fs": { + "timestamp": 1436460392946, + "total": { + "total_in_bytes": 19507089408, + "free_in_bytes": 16909316096, + "available_in_bytes": 15894814720 + }, + "data": [ + { + "path": "/usr/share/elasticsearch/data/elasticsearch/nodes/0", + "mount": "/usr/share/elasticsearch/data", + "dev": "/dev/sda1", + "type": "ext4", + "total_in_bytes": 19507089408, + "free_in_bytes": 16909316096, + "available_in_bytes": 15894814720 + } + ] } } } @@ -641,3 +660,10 @@ var networkExpected = map[string]float64{ "network_tcp_estab_resets": 0, "network_tcp_out_rsts": 0, } + +var fsExpected = map[string]float64{ + "fs_timestamp": 1436460392946, + "fs_total_free_in_bytes": 16909316096, + "fs_total_available_in_bytes": 15894814720, + "fs_total_total_in_bytes": 19507089408, +}