mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-28 15:46:36 +00:00
Use kingpin application for flags
Will be required to pass application object to config file functions. Signed-off-by: Ben Reedy <breed808@breed808.com>
This commit is contained in:
22
exporter.go
22
exporter.go
@@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
_ "net/http/pprof"
|
_ "net/http/pprof"
|
||||||
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -268,36 +269,37 @@ func initWbem() {
|
|||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
var (
|
var (
|
||||||
listenAddress = kingpin.Flag(
|
app = kingpin.New("windows_exporter", "")
|
||||||
|
listenAddress = app.Flag(
|
||||||
"telemetry.addr",
|
"telemetry.addr",
|
||||||
"host:port for exporter.",
|
"host:port for exporter.",
|
||||||
).Default(":9182").String()
|
).Default(":9182").String()
|
||||||
metricsPath = kingpin.Flag(
|
metricsPath = app.Flag(
|
||||||
"telemetry.path",
|
"telemetry.path",
|
||||||
"URL path for surfacing collected metrics.",
|
"URL path for surfacing collected metrics.",
|
||||||
).Default("/metrics").String()
|
).Default("/metrics").String()
|
||||||
maxRequests = kingpin.Flag(
|
maxRequests = app.Flag(
|
||||||
"telemetry.max-requests",
|
"telemetry.max-requests",
|
||||||
"Maximum number of concurrent requests. 0 to disable.",
|
"Maximum number of concurrent requests. 0 to disable.",
|
||||||
).Default("5").Int()
|
).Default("5").Int()
|
||||||
enabledCollectors = kingpin.Flag(
|
enabledCollectors = app.Flag(
|
||||||
"collectors.enabled",
|
"collectors.enabled",
|
||||||
"Comma-separated list of collectors to use. Use '[defaults]' as a placeholder for all the collectors enabled by default.").
|
"Comma-separated list of collectors to use. Use '[defaults]' as a placeholder for all the collectors enabled by default.").
|
||||||
Default(defaultCollectors).String()
|
Default(defaultCollectors).String()
|
||||||
printCollectors = kingpin.Flag(
|
printCollectors = app.Flag(
|
||||||
"collectors.print",
|
"collectors.print",
|
||||||
"If true, print available collectors and exit.",
|
"If true, print available collectors and exit.",
|
||||||
).Bool()
|
).Bool()
|
||||||
timeoutMargin = kingpin.Flag(
|
timeoutMargin = app.Flag(
|
||||||
"scrape.timeout-margin",
|
"scrape.timeout-margin",
|
||||||
"Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads.",
|
"Seconds to subtract from the timeout allowed by the client. Tune to allow for overhead or high loads.",
|
||||||
).Default("0.5").Float64()
|
).Default("0.5").Float64()
|
||||||
)
|
)
|
||||||
|
|
||||||
log.AddFlags(kingpin.CommandLine)
|
log.AddFlags(app)
|
||||||
kingpin.Version(version.Print("windows_exporter"))
|
app.Version(version.Print("windows_exporter"))
|
||||||
kingpin.HelpFlag.Short('h')
|
app.HelpFlag.Short('h')
|
||||||
kingpin.Parse()
|
app.Parse(os.Args[1:])
|
||||||
|
|
||||||
if *printCollectors {
|
if *printCollectors {
|
||||||
collectors := collector.Available()
|
collectors := collector.Available()
|
||||||
|
|||||||
Reference in New Issue
Block a user