Implement process stats.

This commit is contained in:
Orne Brocaar 2015-07-09 20:06:30 +02:00
parent 9cd1344740
commit d90026646f
3 changed files with 35 additions and 0 deletions

View File

@ -17,6 +17,7 @@ type node struct {
Attributes map[string]string `json:"attributes"` Attributes map[string]string `json:"attributes"`
Indices interface{} `json:"indices"` Indices interface{} `json:"indices"`
Os interface{} `json:"os"` Os interface{} `json:"os"`
Process interface{} `json:"process"`
} }
const sampleConfig = ` 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 { if err := e.parseInterface(acc, "os", tags, n.Os); err != nil {
return err return err
} }
if err := e.parseInterface(acc, "process", tags, n.Process); err != nil {
return err
}
} }
return nil return nil

View File

@ -58,4 +58,8 @@ func TestElasticsearch(t *testing.T) {
for key, val := range osExpected { for key, val := range osExpected {
assert.NoError(t, acc.ValidateTaggedValue(key, val, tags)) assert.NoError(t, acc.ValidateTaggedValue(key, val, tags))
} }
for key, val := range processExpected {
assert.NoError(t, acc.ValidateTaggedValue(key, val, tags))
}
} }

View File

@ -154,6 +154,21 @@ const statsResponse = `
"used_in_bytes": 0, "used_in_bytes": 0,
"free_in_bytes": 487997440 "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_free_in_bytes": 477761536,
"os_mem_used_in_bytes": 1621868544, "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,
}