Refactor node_exporter to support collectors.
A collector is a type matching 'Collector' interface. The following collectors where added: - NativeCollector wrapping the original functionality (attributes, load) - GmondCollector scraping ganglia's gmond (based on gmond_exporter) - MuninCollector scraping munin (based on munin_exporter)
This commit is contained in:
parent
a6e8bcb1c4
commit
588ef8b62a
9 changed files with 782 additions and 224 deletions
26
exporter/helper.go
Normal file
26
exporter/helper.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package exporter
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func debug(name string, format string, a ...interface{}) {
|
||||
if *verbose {
|
||||
f := fmt.Sprintf("%s: %s", name, format)
|
||||
log.Printf(f, a...)
|
||||
}
|
||||
}
|
||||
|
||||
func splitToInts(str string, sep string) (ints []int, err error) {
|
||||
for _, part := range strings.Split(str, sep) {
|
||||
i, err := strconv.Atoi(part)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Could not split '%s' because %s is no int: %s", str, part, err)
|
||||
}
|
||||
ints = append(ints, i)
|
||||
}
|
||||
return ints, nil
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue