Skip to content

Commit

Permalink
close r.Body, remove network metrics, updated other sections as needed
Browse files Browse the repository at this point in the history
closes #430
closes #452
  • Loading branch information
jipperinbham authored and sparrc committed Dec 17, 2015
1 parent 4852b5c commit 97ebcc2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 49 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- [#427](https://github.com/influxdb/telegraf/pull/427): zfs plugin: pool stats added. Thanks @allenpetersen!
- [#428](https://github.com/influxdb/telegraf/pull/428): Amazon Kinesis output. Thanks @jimmystewpot!

### Bugfixes
- [#430](https://github.com/influxdb/telegraf/issues/430): Network statistics removed in elasticsearch 2.1. Thanks @jipperinbham!
- [#452](https://github.com/influxdb/telegraf/issues/452): Elasticsearch open file handles error. Thanks @jipperinbham!

## v0.2.4 [2015-12-08]

### Features
Expand Down
6 changes: 4 additions & 2 deletions plugins/elasticsearch/elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type node struct {
Process interface{} `json:"process"`
JVM interface{} `json:"jvm"`
ThreadPool interface{} `json:"thread_pool"`
Network interface{} `json:"network"`
FS interface{} `json:"fs"`
Transport interface{} `json:"transport"`
HTTP interface{} `json:"http"`
Expand Down Expand Up @@ -136,7 +135,6 @@ func (e *Elasticsearch) gatherNodeStats(url string, acc plugins.Accumulator) err
"process": n.Process,
"jvm": n.JVM,
"thread_pool": n.ThreadPool,
"network": n.Network,
"fs": n.FS,
"transport": n.Transport,
"http": n.HTTP,
Expand Down Expand Up @@ -202,7 +200,11 @@ func (e *Elasticsearch) gatherData(url string, v interface{}) error {
if err != nil {
return err
}
defer r.Body.Close()
if r.StatusCode != http.StatusOK {
// NOTE: we are not going to read/discard r.Body under the assumption we'd prefer
// to let the underlying transport close the connection and re-establish a new one for
// future calls.
return fmt.Errorf("elasticsearch: API responded with status-code %d, expected %d", r.StatusCode, http.StatusOK)
}
if err = json.NewDecoder(r.Body).Decode(v); err != nil {
Expand Down
1 change: 0 additions & 1 deletion plugins/elasticsearch/elasticsearch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ func TestElasticsearch(t *testing.T) {
processExpected,
jvmExpected,
threadPoolExpected,
networkExpected,
fsExpected,
transportExpected,
httpExpected,
Expand Down
46 changes: 0 additions & 46 deletions plugins/elasticsearch/testdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,19 +200,11 @@ const statsResponse = `
},
"os": {
"timestamp": 1436460392944,
"uptime_in_millis": 25092,
"load_average": [
0.01,
0.04,
0.05
],
"cpu": {
"sys": 0,
"user": 0,
"idle": 99,
"usage": 0,
"stolen": 0
},
"mem": {
"free_in_bytes": 477761536,
"used_in_bytes": 1621868544,
Expand All @@ -236,8 +228,6 @@ const statsResponse = `
"total_in_millis": 15480
},
"mem": {
"resident_in_bytes": 246382592,
"share_in_bytes": 18747392,
"total_virtual_in_bytes": 4747890688
}
},
Expand Down Expand Up @@ -439,20 +429,6 @@ const statsResponse = `
"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
}
},
"fs": {
"timestamp": 1436460392946,
"total": {
Expand All @@ -464,7 +440,6 @@ const statsResponse = `
{
"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,
Expand Down Expand Up @@ -590,12 +565,6 @@ var osExpected = map[string]float64{
"os_swap_used_in_bytes": 0,
"os_swap_free_in_bytes": 487997440,
"os_timestamp": 1436460392944,
"os_uptime_in_millis": 25092,
"os_cpu_sys": 0,
"os_cpu_user": 0,
"os_cpu_idle": 99,
"os_cpu_usage": 0,
"os_cpu_stolen": 0,
"os_mem_free_percent": 74,
"os_mem_used_percent": 25,
"os_mem_actual_free_in_bytes": 1565470720,
Expand All @@ -605,8 +574,6 @@ var osExpected = map[string]float64{
}

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,
Expand Down Expand Up @@ -756,19 +723,6 @@ var threadPoolExpected = map[string]float64{
"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,
}

var fsExpected = map[string]float64{
"fs_timestamp": 1436460392946,
"fs_total_free_in_bytes": 16909316096,
Expand Down

0 comments on commit 97ebcc2

Please sign in to comment.