Updating aerospike & apache plugins for 0.3.0
This commit is contained in:
parent
50fc3ec974
commit
97a66b73cf
|
@ -247,8 +247,13 @@ func get(key []byte, host string) (map[string]string, error) {
|
||||||
return data, err
|
return data, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func readAerospikeStats(stats map[string]string, acc plugins.Accumulator, host, namespace string) {
|
func readAerospikeStats(
|
||||||
for key, value := range stats {
|
stats map[string]string,
|
||||||
|
acc plugins.Accumulator,
|
||||||
|
host string,
|
||||||
|
namespace string,
|
||||||
|
) {
|
||||||
|
fields := make(map[string]interface{})
|
||||||
tags := map[string]string{
|
tags := map[string]string{
|
||||||
"aerospike_host": host,
|
"aerospike_host": host,
|
||||||
"namespace": "_service",
|
"namespace": "_service",
|
||||||
|
@ -257,16 +262,17 @@ func readAerospikeStats(stats map[string]string, acc plugins.Accumulator, host,
|
||||||
if namespace != "" {
|
if namespace != "" {
|
||||||
tags["namespace"] = namespace
|
tags["namespace"] = namespace
|
||||||
}
|
}
|
||||||
|
for key, value := range stats {
|
||||||
// We are going to ignore all string based keys
|
// We are going to ignore all string based keys
|
||||||
val, err := strconv.ParseInt(value, 10, 64)
|
val, err := strconv.ParseInt(value, 10, 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if strings.Contains(key, "-") {
|
if strings.Contains(key, "-") {
|
||||||
key = strings.Replace(key, "-", "_", -1)
|
key = strings.Replace(key, "-", "_", -1)
|
||||||
}
|
}
|
||||||
acc.Add(key, val, tags)
|
fields[key] = val
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
acc.AddFields("aerospike", fields, tags)
|
||||||
}
|
}
|
||||||
|
|
||||||
func unmarshalMapInfo(infoMap map[string]string, key string) (map[string]string, error) {
|
func unmarshalMapInfo(infoMap map[string]string, key string) (map[string]string, error) {
|
||||||
|
|
|
@ -72,32 +72,33 @@ func (n *Apache) gatherUrl(addr *url.URL, acc plugins.Accumulator) error {
|
||||||
tags := getTags(addr)
|
tags := getTags(addr)
|
||||||
|
|
||||||
sc := bufio.NewScanner(resp.Body)
|
sc := bufio.NewScanner(resp.Body)
|
||||||
|
fields := make(map[string]interface{})
|
||||||
for sc.Scan() {
|
for sc.Scan() {
|
||||||
line := sc.Text()
|
line := sc.Text()
|
||||||
if strings.Contains(line, ":") {
|
if strings.Contains(line, ":") {
|
||||||
|
|
||||||
parts := strings.SplitN(line, ":", 2)
|
parts := strings.SplitN(line, ":", 2)
|
||||||
key, part := strings.Replace(parts[0], " ", "", -1), strings.TrimSpace(parts[1])
|
key, part := strings.Replace(parts[0], " ", "", -1), strings.TrimSpace(parts[1])
|
||||||
|
|
||||||
switch key {
|
switch key {
|
||||||
|
|
||||||
case "Scoreboard":
|
case "Scoreboard":
|
||||||
n.gatherScores(part, acc, tags)
|
for field, value := range n.gatherScores(part) {
|
||||||
|
fields[field] = value
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
value, err := strconv.ParseFloat(part, 64)
|
value, err := strconv.ParseFloat(part, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
acc.Add(key, value, tags)
|
fields[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
acc.AddFields("apache", fields, tags)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[string]string) {
|
func (n *Apache) gatherScores(data string) map[string]interface{} {
|
||||||
|
|
||||||
var waiting, open int = 0, 0
|
var waiting, open int = 0, 0
|
||||||
var S, R, W, K, D, C, L, G, I int = 0, 0, 0, 0, 0, 0, 0, 0, 0
|
var S, R, W, K, D, C, L, G, I int = 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||||
|
|
||||||
|
@ -129,17 +130,20 @@ func (n *Apache) gatherScores(data string, acc plugins.Accumulator, tags map[str
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
acc.Add("scboard_waiting", float64(waiting), tags)
|
fields := map[string]interface{}{
|
||||||
acc.Add("scboard_starting", float64(S), tags)
|
"scboard_waiting": float64(waiting),
|
||||||
acc.Add("scboard_reading", float64(R), tags)
|
"scboard_starting": float64(S),
|
||||||
acc.Add("scboard_sending", float64(W), tags)
|
"scboard_reading": float64(R),
|
||||||
acc.Add("scboard_keepalive", float64(K), tags)
|
"scboard_sending": float64(W),
|
||||||
acc.Add("scboard_dnslookup", float64(D), tags)
|
"scboard_keepalive": float64(K),
|
||||||
acc.Add("scboard_closing", float64(C), tags)
|
"scboard_dnslookup": float64(D),
|
||||||
acc.Add("scboard_logging", float64(L), tags)
|
"scboard_closing": float64(C),
|
||||||
acc.Add("scboard_finishing", float64(G), tags)
|
"scboard_logging": float64(L),
|
||||||
acc.Add("scboard_idle_cleanup", float64(I), tags)
|
"scboard_finishing": float64(G),
|
||||||
acc.Add("scboard_open", float64(open), tags)
|
"scboard_idle_cleanup": float64(I),
|
||||||
|
"scboard_open": float64(open),
|
||||||
|
}
|
||||||
|
return fields
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get tag(s) for the apache plugin
|
// Get tag(s) for the apache plugin
|
||||||
|
|
Loading…
Reference in New Issue