0.3.0: zookeeper and zfs
This commit is contained in:
parent
6698d195d8
commit
c1e1f2ace4
|
@ -88,15 +88,15 @@ func gatherPoolStats(pool poolInfo, acc plugins.Accumulator) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
tag := map[string]string{"pool": pool.name}
|
tag := map[string]string{"pool": pool.name}
|
||||||
|
fields := make(map[string]interface{})
|
||||||
for i := 0; i < keyCount; i++ {
|
for i := 0; i < keyCount; i++ {
|
||||||
value, err := strconv.ParseInt(values[i], 10, 64)
|
value, err := strconv.ParseInt(values[i], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
fields[keys[i]] = value
|
||||||
acc.Add(keys[i], value, tag)
|
|
||||||
}
|
}
|
||||||
|
acc.AddFields("zfs_pool", fields, tag)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -124,6 +124,7 @@ func (z *Zfs) Gather(acc plugins.Accumulator) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fields := make(map[string]interface{})
|
||||||
for _, metric := range kstatMetrics {
|
for _, metric := range kstatMetrics {
|
||||||
lines, err := internal.ReadLines(kstatPath + "/" + metric)
|
lines, err := internal.ReadLines(kstatPath + "/" + metric)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -140,9 +141,10 @@ func (z *Zfs) Gather(acc plugins.Accumulator) error {
|
||||||
key := metric + "_" + rawData[0]
|
key := metric + "_" + rawData[0]
|
||||||
rawValue := rawData[len(rawData)-1]
|
rawValue := rawData[len(rawData)-1]
|
||||||
value, _ := strconv.ParseInt(rawValue, 10, 64)
|
value, _ := strconv.ParseInt(rawValue, 10, 64)
|
||||||
acc.Add(key, value, tags)
|
fields[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
acc.AddFields("zfs", fields, tags)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,35 +67,37 @@ func (z *Zookeeper) gatherServer(address string, acc plugins.Accumulator) error
|
||||||
defer c.Close()
|
defer c.Close()
|
||||||
|
|
||||||
fmt.Fprintf(c, "%s\n", "mntr")
|
fmt.Fprintf(c, "%s\n", "mntr")
|
||||||
|
|
||||||
rdr := bufio.NewReader(c)
|
rdr := bufio.NewReader(c)
|
||||||
|
|
||||||
scanner := bufio.NewScanner(rdr)
|
scanner := bufio.NewScanner(rdr)
|
||||||
|
|
||||||
|
service := strings.Split(address, ":")
|
||||||
|
if len(service) != 2 {
|
||||||
|
return fmt.Errorf("Invalid service address: %s", address)
|
||||||
|
}
|
||||||
|
tags := map[string]string{"server": service[0], "port": service[1]}
|
||||||
|
|
||||||
|
fields := make(map[string]interface{})
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
line := scanner.Text()
|
line := scanner.Text()
|
||||||
|
|
||||||
re := regexp.MustCompile(`^zk_(\w+)\s+([\w\.\-]+)`)
|
re := regexp.MustCompile(`^zk_(\w+)\s+([\w\.\-]+)`)
|
||||||
parts := re.FindStringSubmatch(string(line))
|
parts := re.FindStringSubmatch(string(line))
|
||||||
|
|
||||||
service := strings.Split(address, ":")
|
if len(parts) != 3 {
|
||||||
|
|
||||||
if len(parts) != 3 || len(service) != 2 {
|
|
||||||
return fmt.Errorf("unexpected line in mntr response: %q", line)
|
return fmt.Errorf("unexpected line in mntr response: %q", line)
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := map[string]string{"server": service[0], "port": service[1]}
|
|
||||||
|
|
||||||
measurement := strings.TrimPrefix(parts[1], "zk_")
|
measurement := strings.TrimPrefix(parts[1], "zk_")
|
||||||
sValue := string(parts[2])
|
sValue := string(parts[2])
|
||||||
|
|
||||||
iVal, err := strconv.ParseInt(sValue, 10, 64)
|
iVal, err := strconv.ParseInt(sValue, 10, 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
acc.Add(measurement, iVal, tags)
|
fields[measurement] = iVal
|
||||||
} else {
|
} else {
|
||||||
acc.Add(measurement, sValue, tags)
|
fields[measurement] = sValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
acc.AddFields("zookeeper", fields, tags)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue