clean up and finish aerospike refactor & readme

This commit is contained in:
Cameron Sparr 2016-07-19 11:15:09 +01:00
parent 0be69b8a44
commit 5f14ad9fa1
3 changed files with 63 additions and 262 deletions

File diff suppressed because one or more lines are too long

View File

@ -72,18 +72,17 @@ func (a *Aerospike) gatherServer(hostport string, acc telegraf.Accumulator) erro
nodes := c.GetNodes() nodes := c.GetNodes()
for _, n := range nodes { for _, n := range nodes {
tags := map[string]string{ tags := map[string]string{
"node_name": n.GetName(),
"aerospike_host": hostport, "aerospike_host": hostport,
} }
fields := make(map[string]interface{}) fields := map[string]interface{}{
"node_name": n.GetName(),
}
stats, err := as.RequestNodeStats(n) stats, err := as.RequestNodeStats(n)
if err != nil { if err != nil {
return err return err
} }
for k, v := range stats { for k, v := range stats {
if iv, err := strconv.ParseInt(v, 10, 64); err == nil { fields[strings.Replace(k, "-", "_", -1)] = parseValue(v)
fields[strings.Replace(k, "-", "_", -1)] = iv
}
} }
acc.AddFields("aerospike_node", fields, tags, time.Now()) acc.AddFields("aerospike_node", fields, tags, time.Now())
@ -94,9 +93,13 @@ func (a *Aerospike) gatherServer(hostport string, acc telegraf.Accumulator) erro
namespaces := strings.Split(info["namespaces"], ";") namespaces := strings.Split(info["namespaces"], ";")
for _, namespace := range namespaces { for _, namespace := range namespaces {
nTags := copyTags(tags) nTags := map[string]string{
"aerospike_host": hostport,
}
nTags["namespace"] = namespace nTags["namespace"] = namespace
nFields := make(map[string]interface{}) nFields := map[string]interface{}{
"node_name": n.GetName(),
}
info, err := as.RequestNodeInfo(n, "namespace/"+namespace) info, err := as.RequestNodeInfo(n, "namespace/"+namespace)
if err != nil { if err != nil {
continue continue
@ -107,9 +110,7 @@ func (a *Aerospike) gatherServer(hostport string, acc telegraf.Accumulator) erro
if len(parts) < 2 { if len(parts) < 2 {
continue continue
} }
if iv, err := strconv.ParseInt(parts[1], 10, 64); err == nil { nFields[strings.Replace(parts[0], "-", "_", -1)] = parseValue(parts[1])
nFields[strings.Replace(parts[0], "-", "_", -1)] = iv
}
} }
acc.AddFields("aerospike_namespace", nFields, nTags, time.Now()) acc.AddFields("aerospike_namespace", nFields, nTags, time.Now())
} }
@ -117,6 +118,16 @@ func (a *Aerospike) gatherServer(hostport string, acc telegraf.Accumulator) erro
return nil return nil
} }
func parseValue(v string) interface{} {
if parsed, err := strconv.ParseInt(v, 10, 64); err == nil {
return parsed
} else if parsed, err := strconv.ParseBool(v); err == nil {
return parsed
} else {
return v
}
}
func copyTags(m map[string]string) map[string]string { func copyTags(m map[string]string) map[string]string {
out := make(map[string]string) out := make(map[string]string)
for k, v := range m { for k, v := range m {

View File

@ -1,18 +1,18 @@
# Ceph Storage Input Plugin # Ceph Storage Input Plugin
Collects performance metrics from the MON and OSD nodes in a Ceph storage cluster. Collects performance metrics from the MON and OSD nodes in a Ceph storage cluster.
The plugin works by scanning the configured SocketDir for OSD and MON socket files. When it finds The plugin works by scanning the configured SocketDir for OSD and MON socket files. When it finds
a MON socket, it runs **ceph --admin-daemon $file perfcounters_dump**. For OSDs it runs **ceph --admin-daemon $file perf dump** a MON socket, it runs **ceph --admin-daemon $file perfcounters_dump**. For OSDs it runs **ceph --admin-daemon $file perf dump**
The resulting JSON is parsed and grouped into collections, based on top-level key. Top-level keys are The resulting JSON is parsed and grouped into collections, based on top-level key. Top-level keys are
used as collection tags, and all sub-keys are flattened. For example: used as collection tags, and all sub-keys are flattened. For example:
``` ```
{ {
"paxos": { "paxos": {
"refresh": 9363435, "refresh": 9363435,
"refresh_latency": { "refresh_latency": {
"avgcount": 9363435, "avgcount": 9363435,
"sum": 5378.794002000 "sum": 5378.794002000
} }
@ -50,7 +50,7 @@ Would be parsed into the following metrics, all of which would be tagged with co
### Measurements & Fields: ### Measurements & Fields:
All fields are collected under the **ceph** measurement and stored as float64s. For a full list of fields, see the sample perf dumps in ceph_test.go. All fields are collected under the **ceph** measurement and stored as float64s. For a full list of fields, see the sample perf dumps in ceph_test.go.
### Tags: ### Tags:
@ -95,7 +95,7 @@ All measurements will have the following tags:
- throttle-objecter_ops - throttle-objecter_ops
- throttle-osd_client_bytes - throttle-osd_client_bytes
- throttle-osd_client_messages - throttle-osd_client_messages
### Example Output: ### Example Output: