add 4 more suggested smart values

This commit is contained in:
lukas-heiligenbrunner 2022-05-05 12:17:21 +02:00
parent 965f9326eb
commit bd5d4414bd

View File

@ -33,7 +33,7 @@ func getDiskInfo(diskpath string) *DiskInfo {
type Item struct {
Name string `json:"name"`
Raw struct {
Value uint64 `json:"value"`
Value int64 `json:"value"`
} `json:"raw"`
}
@ -88,6 +88,13 @@ func checkSmartAttributes(diskpath string, isSeagate bool, isHdd bool) {
fmt.Println("Raw_Read_Error_Rate: " + evalStrZero(rrerrrate))
fmt.Println("Reallocated_Sector_Ct: " + evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Reallocated_Sector_Ct")))
// todo further investigate if this smart attributes can occur within hdds/ssds
// https://www.backblaze.com/blog/what-smart-stats-indicate-hard-drive-failures/
fmt.Println("Reported_Uncorrect: " + evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Reported_Uncorrect")))
fmt.Println("Command_Timeout: " + evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Command_Timeout")))
fmt.Println("Current_Pending_Sector: " + evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Current_Pending_Sector")))
fmt.Println("Offline_Uncorrectable: " + evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Offline_Uncorrectable")))
// there are some additinoal hdd smart values
if isHdd {
rrerrrate = getItemValue(rawattr.AtaSmartAttr.Table, "Seek_Error_Rate")
@ -102,19 +109,21 @@ func checkSmartAttributes(diskpath string, isSeagate bool, isHdd bool) {
}
}
func evalStrZero(nr uint64) string {
if nr == 0 {
func evalStrZero(nr int64) string {
if nr < 0 {
return "N/A"
} else if nr == 0 {
return "\tPASS"
} else {
return fmt.Sprintf("\tFAIL :: raw value=%d", nr)
}
}
func getItemValue(arr []Item, name string) uint64 {
func getItemValue(arr []Item, name string) int64 {
for i := range arr {
if arr[i].Name == name {
return arr[i].Raw.Value
}
}
return 0
return -1
}