mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-26 14:46:35 +00:00
update: fix naming flags (renamed --collector.updates.* to --collector.update.*) (click PR number for more information) (#1986)
Signed-off-by: Melody Sofia Eroshevich <se@cloudeteer.de>
This commit is contained in:
@@ -84,16 +84,58 @@ func NewWithFlags(app *kingpin.Application) *Collector {
|
|||||||
config: ConfigDefaults,
|
config: ConfigDefaults,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
online bool
|
||||||
|
scrapeInterval time.Duration
|
||||||
|
)
|
||||||
|
|
||||||
app.Flag(
|
app.Flag(
|
||||||
"collector.updates.online",
|
"collector.updates.online",
|
||||||
|
"Deprecated: Please use collector.update.online instead",
|
||||||
|
).Default(strconv.FormatBool(ConfigDefaults.online)).BoolVar(&online)
|
||||||
|
|
||||||
|
app.Flag(
|
||||||
|
"collector.updates.scrape-interval",
|
||||||
|
"Deprecated: Please use collector.update.scrape-interval instead",
|
||||||
|
).Default(ConfigDefaults.scrapeInterval.String()).DurationVar(&scrapeInterval)
|
||||||
|
|
||||||
|
app.Flag(
|
||||||
|
"collector.update.online",
|
||||||
"Whether to search for updates online.",
|
"Whether to search for updates online.",
|
||||||
).Default(strconv.FormatBool(ConfigDefaults.online)).BoolVar(&c.config.online)
|
).Default(strconv.FormatBool(ConfigDefaults.online)).BoolVar(&c.config.online)
|
||||||
|
|
||||||
app.Flag(
|
app.Flag(
|
||||||
"collector.updates.scrape-interval",
|
"collector.update.scrape-interval",
|
||||||
"Define the interval of scraping Windows Update information.",
|
"Define the interval of scraping Windows Update information.",
|
||||||
).Default(ConfigDefaults.scrapeInterval.String()).DurationVar(&c.config.scrapeInterval)
|
).Default(ConfigDefaults.scrapeInterval.String()).DurationVar(&c.config.scrapeInterval)
|
||||||
|
|
||||||
|
app.Action(func(*kingpin.ParseContext) error {
|
||||||
|
// Use deprecated flags only if new ones weren't explicitly set
|
||||||
|
if online {
|
||||||
|
// If the new flag is set, ignore the old one
|
||||||
|
if !c.config.online {
|
||||||
|
c.config.online = online
|
||||||
|
}
|
||||||
|
|
||||||
|
slog.Warn("Warning: --collector.updates.online is deprecated, use --collector.update.online instead.",
|
||||||
|
slog.String("collector", Name),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if scrapeInterval != ConfigDefaults.scrapeInterval {
|
||||||
|
// If the new flag is set, ignore the old one
|
||||||
|
if c.config.scrapeInterval != scrapeInterval {
|
||||||
|
c.config.scrapeInterval = scrapeInterval
|
||||||
|
}
|
||||||
|
|
||||||
|
slog.Warn("Warning: --collector.updates.scrape-interval is deprecated, use --collector.update.scrape-interval instead.",
|
||||||
|
slog.String("collector", Name),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,7 +163,7 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
|||||||
|
|
||||||
c.pendingUpdate = prometheus.NewDesc(
|
c.pendingUpdate = prometheus.NewDesc(
|
||||||
prometheus.BuildFQName(types.Namespace, Name, "pending_info"),
|
prometheus.BuildFQName(types.Namespace, Name, "pending_info"),
|
||||||
"Pending Windows Updates",
|
"Expose information for a single pending update item",
|
||||||
[]string{"category", "severity", "title"},
|
[]string{"category", "severity", "title"},
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user