Merge branch 'more_params' into 'master'
add 4 more suggested smart values See merge request lukas/diskhealth!2
This commit is contained in:
commit
4eece6633e
@ -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"`
|
||||
}
|
||||
|
||||
@ -75,6 +75,10 @@ func getTemp(diskpath string) (uint32, uint32, uint32) {
|
||||
return uint32(max), uint32(min), uint32(currtemp)
|
||||
}
|
||||
|
||||
func printAligned(paramname string, valuestr string) {
|
||||
fmt.Printf("%-24v%s\n", paramname+":", valuestr)
|
||||
}
|
||||
|
||||
func checkSmartAttributes(diskpath string, isSeagate bool, isHdd bool) {
|
||||
rawattr := getSmartValues(diskpath)
|
||||
|
||||
@ -85,10 +89,17 @@ func checkSmartAttributes(diskpath string, isSeagate bool, isHdd bool) {
|
||||
// error count| operation count
|
||||
rrerrrate = rrerrrate >> 32
|
||||
}
|
||||
fmt.Println("Raw_Read_Error_Rate: " + evalStrZero(rrerrrate))
|
||||
fmt.Println("Reallocated_Sector_Ct: " + evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Reallocated_Sector_Ct")))
|
||||
printAligned("Raw_Read_Error_Rate", evalStrZero(rrerrrate))
|
||||
printAligned("Reallocated_Sector_Ct", evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Reallocated_Sector_Ct")))
|
||||
|
||||
// there are some additinoal hdd smart values
|
||||
// todo further investigate if this smart attributes can occur within hdds/ssds
|
||||
// https://www.backblaze.com/blog/what-smart-stats-indicate-hard-drive-failures/
|
||||
printAligned("Reported_Uncorrect", evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Reported_Uncorrect")))
|
||||
printAligned("Command_Timeout", evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Command_Timeout")))
|
||||
printAligned("Current_Pending_Sector", evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Current_Pending_Sector")))
|
||||
printAligned("Offline_Uncorrectable", evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Offline_Uncorrectable")))
|
||||
|
||||
// there are some additinoal hdd only smart values
|
||||
if isHdd {
|
||||
rrerrrate = getItemValue(rawattr.AtaSmartAttr.Table, "Seek_Error_Rate")
|
||||
if isSeagate {
|
||||
@ -96,25 +107,29 @@ func checkSmartAttributes(diskpath string, isSeagate bool, isHdd bool) {
|
||||
// error count| operation count
|
||||
rrerrrate = rrerrrate >> 32
|
||||
}
|
||||
fmt.Println("Seek_Error_Rate:\t" + evalStrZero(rrerrrate))
|
||||
fmt.Println("Spin_Retry_Count:\t" + evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Spin_Retry_Count")))
|
||||
fmt.Println("Spin_Up_Time:\t\t" + evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Spin_Up_Time")))
|
||||
}
|
||||
}
|
||||
|
||||
func evalStrZero(nr uint64) string {
|
||||
if nr == 0 {
|
||||
return "\tPASS"
|
||||
printAligned("Seek_Error_Rate", evalStrZero(rrerrrate))
|
||||
printAligned("Spin_Retry_Count", evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Spin_Retry_Count")))
|
||||
printAligned("Spin_Up_Time", evalStrZero(getItemValue(rawattr.AtaSmartAttr.Table, "Spin_Up_Time")))
|
||||
} else {
|
||||
return fmt.Sprintf("\tFAIL :: raw value=%d", nr)
|
||||
// todo ssd only parameters
|
||||
}
|
||||
}
|
||||
|
||||
func getItemValue(arr []Item, name string) uint64 {
|
||||
func evalStrZero(nr int64) string {
|
||||
if nr < 0 {
|
||||
return "N/A"
|
||||
} else if nr == 0 {
|
||||
return "PASS"
|
||||
} else {
|
||||
return fmt.Sprintf("FAIL :: raw value=%d", nr)
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user