Replace --collectors.enabled with per-collector flags (#640)

* Move NodeCollector into package collector

* Refactor collector enabling

* Update README with new collector enabled flags

* Fix out-of-date inline flag reference syntax

* Use new flags in end-to-end tests

* Add flag to disable all default collectors

* Track if a flag has been set explicitly

* Add --collectors.disable-defaults to README

* Revert disable-defaults flag

* Shorten flags

* Fixup timex collector registration

* Fix end-to-end tests

* Change procfs and sysfs path flags

* Fix review comments
This commit is contained in:
Calle Pettersson 2017-09-28 15:06:26 +02:00 committed by Johannes 'fish' Ziemke
commit 859a825bb8
58 changed files with 410 additions and 406 deletions

View file

@ -34,44 +34,44 @@ type statCollector struct {
}
func init() {
Factories["stat"] = NewStatCollector
registerCollector("stat", defaultEnabled, NewStatCollector)
}
// NewStatCollector returns a new Collector exposing kernel/system statistics.
func NewStatCollector() (Collector, error) {
return &statCollector{
cpu: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "cpu"),
prometheus.BuildFQName(namespace, "", "cpu"),
"Seconds the cpus spent in each mode.",
[]string{"cpu", "mode"}, nil,
),
intr: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "intr"),
prometheus.BuildFQName(namespace, "", "intr"),
"Total number of interrupts serviced.",
nil, nil,
),
ctxt: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "context_switches"),
prometheus.BuildFQName(namespace, "", "context_switches"),
"Total number of context switches.",
nil, nil,
),
forks: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "forks"),
prometheus.BuildFQName(namespace, "", "forks"),
"Total number of forks.",
nil, nil,
),
btime: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "boot_time"),
prometheus.BuildFQName(namespace, "", "boot_time"),
"Node boot time, in unixtime.",
nil, nil,
),
procsRunning: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "procs_running"),
prometheus.BuildFQName(namespace, "", "procs_running"),
"Number of processes in runnable state.",
nil, nil,
),
procsBlocked: prometheus.NewDesc(
prometheus.BuildFQName(Namespace, "", "procs_blocked"),
prometheus.BuildFQName(namespace, "", "procs_blocked"),
"Number of processes blocked waiting for I/O to complete.",
nil, nil,
),