mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-27 23:26:37 +00:00
Check that collectors given on --collectors.enabled exist before trying to construct them
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package collector
|
package collector
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -72,7 +73,11 @@ func Available() []string {
|
|||||||
return cs
|
return cs
|
||||||
}
|
}
|
||||||
func Build(collector string) (Collector, error) {
|
func Build(collector string) (Collector, error) {
|
||||||
return builders[collector]()
|
builder, exists := builders[collector]
|
||||||
|
if !exists {
|
||||||
|
return nil, fmt.Errorf("Unknown collector %q", collector)
|
||||||
|
}
|
||||||
|
return builder()
|
||||||
}
|
}
|
||||||
func getPerfQuery(collectors []string) string {
|
func getPerfQuery(collectors []string) string {
|
||||||
parts := make([]string, 0, len(collectors))
|
parts := make([]string, 0, len(collectors))
|
||||||
|
|||||||
Reference in New Issue
Block a user