diff --git a/collector/diskstats_linux.go b/collector/diskstats_linux.go index 7d3678063f..a37dc4dad3 100644 --- a/collector/diskstats_linux.go +++ b/collector/diskstats_linux.go @@ -314,7 +314,7 @@ func (c *diskstatsCollector) Update(ch chan<- prometheus.Metric) error { smartJSON, exists := getDeviceResult(smartctlResult, stats.DeviceName) if !exists { - c.logger.Info("get device result from smartctl failed") + c.logger.Info("get device result from smartctl failed", "deviceName", stats.DeviceName) } info, err := getUdevDeviceProperties(stats.MajorNumber, stats.MinorNumber) diff --git a/collector/smartctl.go b/collector/smartctl.go index 156d41083b..62f3597bde 100644 --- a/collector/smartctl.go +++ b/collector/smartctl.go @@ -62,6 +62,9 @@ func (s *Smartctl) scan() ([]scanDevice, error) { } devices := make([]scanDevice, 0) for _, device := range scan.Devices { + if device.OpenError != "" { + continue + } dev := scanDevice{ Name: device.Name, Type: device.Type, @@ -273,9 +276,10 @@ type smartctlScanJSON struct { ExitStatus int `json:"exit_status"` } `json:"smartctl"` Devices []struct { - Name string `json:"name"` - InfoName string `json:"info_name"` - Type string `json:"type"` - Protocol string `json:"protocol"` + Name string `json:"name"` + InfoName string `json:"info_name"` + Type string `json:"type"` + Protocol string `json:"protocol"` + OpenError string `json:"open_error,omitempty"` } `json:"devices"` }