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

This commit is contained in:
Jan-Otto Kröpke
2025-07-20 08:15:21 +02:00
committed by GitHub
parent bf281d9e08
commit fb9f1fe141

View File

@@ -36,7 +36,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
@@ -71,7 +73,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",
@@ -146,7 +150,7 @@ var (
"Error", "Error",
"Degraded", "Degraded",
"Unknown", "Unknown",
"Pred fail", "Pred Fail",
"Starting", "Starting",
"Stopping", "Stopping",
"Service", "Service",