Split native collector into it's component parts and make them enablable.
Last login is disabled by default as it's broken on ubuntu 12.04 Interrupts is disabled by default as it's very granular and we'll have total interrupts from /proc/stat Allow ignoring devices from diskstats, ignore ram and loop devices by default. Use glog for logging.
This commit is contained in:
parent
964cdbfcc9
commit
25ea90369c
14 changed files with 747 additions and 516 deletions
43
collector/attributes.go
Normal file
43
collector/attributes.go
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
// +build !noattributes
|
||||
|
||||
package collector
|
||||
|
||||
import (
|
||||
"github.com/golang/glog"
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
||||
var (
|
||||
attributes = prometheus.NewGauge()
|
||||
)
|
||||
|
||||
type attributesCollector struct {
|
||||
registry prometheus.Registry
|
||||
config Config
|
||||
}
|
||||
|
||||
func init() {
|
||||
Factories["attributes"] = NewAttributesCollector
|
||||
}
|
||||
|
||||
// Takes a config struct and prometheus registry and returns a new Collector exposing
|
||||
// labels from the config.
|
||||
func NewAttributesCollector(config Config, registry prometheus.Registry) (Collector, error) {
|
||||
c := attributesCollector{
|
||||
config: config,
|
||||
registry: registry,
|
||||
}
|
||||
registry.Register(
|
||||
"node_attributes",
|
||||
"node_exporter attributes",
|
||||
prometheus.NilLabels,
|
||||
attributes,
|
||||
)
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
func (c *attributesCollector) Update() (updates int, err error) {
|
||||
glog.V(1).Info("Set node_attributes{%v}: 1", c.config.Attributes)
|
||||
attributes.Set(c.config.Attributes, 1)
|
||||
return updates, err
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue