WIP - start supporting NVME and SCSI drive smart data.
Added addiitonal log message data for Smartctl exit ccode.
This commit is contained in:
@@ -135,3 +135,23 @@ func (c *BaseCollector) ExecCmd(cmdName string, cmdArgs []string, workingDir str
|
||||
return stdBuffer.String(), err
|
||||
|
||||
}
|
||||
|
||||
func (c *BaseCollector) LogSmartctlExitCode(exitCode int) {
|
||||
if exitCode&0x01 != 0 {
|
||||
c.logger.Errorln("smartctl could not parse commandline")
|
||||
} else if exitCode&0x02 != 0 {
|
||||
c.logger.Errorln("smartctl could not open device")
|
||||
} else if exitCode&0x04 != 0 {
|
||||
c.logger.Errorln("smartctl detected a checksum error")
|
||||
} else if exitCode&0x08 != 0 {
|
||||
c.logger.Errorln("smartctl detected a failing disk ")
|
||||
} else if exitCode&0x10 != 0 {
|
||||
c.logger.Errorln("smartctl detected a disk in pre-fail")
|
||||
} else if exitCode&0x20 != 0 {
|
||||
c.logger.Errorln("smartctl detected a disk close to failure")
|
||||
} else if exitCode&0x40 != 0 {
|
||||
c.logger.Errorln("smartctl detected a error log with errors")
|
||||
} else if exitCode&0x80 != 0 {
|
||||
c.logger.Errorln("smartctl detected a self test log with errors")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,6 +98,7 @@ func (mc *MetricsCollector) Collect(wg *sync.WaitGroup, deviceWWN string, device
|
||||
if exitError, ok := err.(*exec.ExitError); ok {
|
||||
// smartctl command exited with an error, we should still push the data to the API server
|
||||
mc.logger.Errorf("smartctl returned an error code (%d) while processing %s\n", exitError.ExitCode(), deviceName)
|
||||
mc.LogSmartctlExitCode(exitError.ExitCode())
|
||||
mc.Publish(deviceWWN, resultBytes)
|
||||
} else {
|
||||
mc.logger.Errorf("error while attempting to execute smartctl: %s\n", deviceName)
|
||||
|
||||
Reference in New Issue
Block a user