diskdrive: fix not exposing state "Pred Fail" (#2101)

This commit is contained in:
Jan-Otto Kröpke
2025-06-30 19:55:45 +02:00
committed by GitHub
parent 116203fd19
commit 492f3af317

View File

@@ -38,7 +38,9 @@ var ConfigDefaults = Config{}
// A Collector is a Prometheus Collector for a few WMI metrics in Win32_DiskDrive. // A Collector is a Prometheus Collector for a few WMI metrics in Win32_DiskDrive.
type Collector struct { type Collector struct {
config Config config Config
logger *slog.Logger
miSession *mi.Session miSession *mi.Session
miQuery mi.Query miQuery mi.Query
@@ -73,7 +75,9 @@ func (c *Collector) Close() error {
return nil return nil
} }
func (c *Collector) Build(_ *slog.Logger, miSession *mi.Session) error { func (c *Collector) Build(logger *slog.Logger, miSession *mi.Session) error {
c.logger = logger.With(slog.String("collector", Name))
c.diskInfo = prometheus.NewDesc( c.diskInfo = prometheus.NewDesc(
prometheus.BuildFQName(types.Namespace, Name, "info"), prometheus.BuildFQName(types.Namespace, Name, "info"),
"General drive information", "General drive information",
@@ -148,7 +152,7 @@ var (
"Error", "Error",
"Degraded", "Degraded",
"Unknown", "Unknown",
"Pred fail", "Pred Fail",
"Starting", "Starting",
"Stopping", "Stopping",
"Service", "Service",