Remove fluent-style kingpin

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2023-04-16 11:45:07 +02:00
parent a105e088b3
commit da6898afc4
15 changed files with 487 additions and 252 deletions

View File

@@ -16,15 +16,14 @@ import (
"golang.org/x/sys/windows/svc/mgr"
)
const (
FlagServiceWhereClause = "collector.service.services-where"
FlagServiceUseAPI = "collector.service.use-api"
)
var (
serviceWhereClause = kingpin.Flag(
"collector.service.services-where",
"WQL 'where' clause to use in WMI metrics query. Limits the response to the services you specify and reduces the size of the response.",
).Default("").String()
useAPI = kingpin.Flag(
"collector.service.use-api",
"Use API calls to collect service data instead of WMI. Flag 'collector.service.services-where' won't be effective.",
).Default("false").Bool()
serviceWhereClause *string
useAPI *bool
)
// A serviceCollector is a Prometheus collector for WMI Win32_Service metrics
@@ -37,6 +36,18 @@ type serviceCollector struct {
queryWhereClause string
}
// newServiceCollectorFlags ...
func newServiceCollectorFlags(app *kingpin.Application) {
serviceWhereClause = app.Flag(
FlagServiceWhereClause,
"WQL 'where' clause to use in WMI metrics query. Limits the response to the services you specify and reduces the size of the response.",
).Default("").String()
useAPI = app.Flag(
FlagServiceUseAPI,
"Use API calls to collect service data instead of WMI. Flag 'collector.service.services-where' won't be effective.",
).Default("false").Bool()
}
// newserviceCollector ...
func newserviceCollector() (Collector, error) {
const subsystem = "service"