Skip to content

Commit 3a05ee0

Browse files
authored
Merge pull request #5 from beclab/fix/oepndev
fix: omit open error device
2 parents b5d9151 + 299f9f9 commit 3a05ee0

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

collector/diskstats_linux.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ func (c *diskstatsCollector) Update(ch chan<- prometheus.Metric) error {
314314

315315
smartJSON, exists := getDeviceResult(smartctlResult, stats.DeviceName)
316316
if !exists {
317-
c.logger.Info("get device result from smartctl failed")
317+
c.logger.Info("get device result from smartctl failed", "deviceName", stats.DeviceName)
318318
}
319319

320320
info, err := getUdevDeviceProperties(stats.MajorNumber, stats.MinorNumber)

collector/smartctl.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ func (s *Smartctl) scan() ([]scanDevice, error) {
6262
}
6363
devices := make([]scanDevice, 0)
6464
for _, device := range scan.Devices {
65+
if device.OpenError != "" {
66+
continue
67+
}
6568
dev := scanDevice{
6669
Name: device.Name,
6770
Type: device.Type,
@@ -273,9 +276,10 @@ type smartctlScanJSON struct {
273276
ExitStatus int `json:"exit_status"`
274277
} `json:"smartctl"`
275278
Devices []struct {
276-
Name string `json:"name"`
277-
InfoName string `json:"info_name"`
278-
Type string `json:"type"`
279-
Protocol string `json:"protocol"`
279+
Name string `json:"name"`
280+
InfoName string `json:"info_name"`
281+
Type string `json:"type"`
282+
Protocol string `json:"protocol"`
283+
OpenError string `json:"open_error,omitempty"`
280284
} `json:"devices"`
281285
}

0 commit comments

Comments
 (0)