-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extend self-test log processing #151
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ package main | |
|
||
import ( | ||
"fmt" | ||
"strconv" | ||
"strings" | ||
|
||
"github.com/go-kit/log" | ||
|
@@ -69,6 +70,7 @@ func (smart *SMARTctl) Collect() { | |
smart.mineDeviceSCTStatus() | ||
smart.mineDeviceStatistics() | ||
smart.mineDeviceErrorLog() | ||
smart.mineDeviceSelfTest() | ||
smart.mineDeviceSelfTestLog() | ||
smart.mineDeviceERC() | ||
smart.minePercentageUsed() | ||
|
@@ -399,6 +401,50 @@ func (smart *SMARTctl) mineDeviceErrorLog() { | |
} | ||
} | ||
|
||
func (smart *SMARTctl) mineDeviceSelfTest() { | ||
validTypes := map[int]string{ | ||
255: "vendor", | ||
129: "short_captive", | ||
2: "long", | ||
1: "short", | ||
} | ||
|
||
// assume the table will always be in descending order | ||
processedTypes := make(map[string]bool) | ||
|
||
for _, logEntry := range smart.json.Get("ata_smart_self_test_log.standard.table").Array() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should accept either |
||
testType := int(logEntry.Get("type.value").Int()) | ||
testTime := float64(logEntry.Get("lifetime_hours").Int()) | ||
testRunningIndicator := int(logEntry.Get("status.value").Int()) | ||
testStatus := strconv.FormatBool(logEntry.Get("status.passed").Bool()) | ||
|
||
// stick with seconds | ||
testTime = testTime * 60 * 60 | ||
|
||
// skip running tests | ||
if testRunningIndicator != 0 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not correct, from one of my systems:
I don't have any SATA drives w/ failing checks to compare presentlyy, but I worry they are also non-zero. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, it's definetly in need of work; also in the smartctl sources:
So if it's 0xF then skip it as running; otherwise map the error. |
||
continue | ||
} | ||
|
||
logTestType, exists := validTypes[testType] | ||
if !exists { | ||
logTestType = "unknown" | ||
} | ||
|
||
if !processedTypes[logTestType] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is implicitly trusting that the tests appear in newest to oldest order. I don't know if I trust drives enough for that. |
||
smart.ch <- prometheus.MustNewConstMetric( | ||
metricDeviceSelfTest, | ||
prometheus.GaugeValue, | ||
testTime, | ||
smart.device.device, | ||
logTestType, | ||
testStatus, | ||
) | ||
processedTypes[logTestType] = true | ||
} | ||
} | ||
} | ||
|
||
func (smart *SMARTctl) mineDeviceSelfTestLog() { | ||
for logType, status := range smart.json.Get("ata_smart_self_test_log").Map() { | ||
smart.ch <- prometheus.MustNewConstMetric( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from smartctl sources: