From bd5d4414bd97cf8ff6225e597b1e19883fb18188 Mon Sep 17 00:00:00 2001 From: lukas-heiligenbrunner Date: Thu, 5 May 2022 12:17:21 +0200 Subject: [PATCH] add 4 more suggested smart values --- smartdiskinfo.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/smartdiskinfo.go b/smartdiskinfo.go index 5df8491..b3c2e2c 100644 --- a/smartdiskinfo.go +++ b/smartdiskinfo.go @@ -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 }