Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
float
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ai3
float
Commits
5506e931
Commit
5506e931
authored
5 months ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Account for 16-bit overflow in SMART self-test lifetime_hours parameter
parent
ee7e812c
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
roles/float-base/files/node-exporter-scripts/smartmon.py
+16
-1
16 additions, 1 deletion
roles/float-base/files/node-exporter-scripts/smartmon.py
with
16 additions
and
1 deletion
roles/float-base/files/node-exporter-scripts/smartmon.py
+
16
−
1
View file @
5506e931
...
...
@@ -191,12 +191,26 @@ def smartd_devices(config='/etc/smartd.conf'):
yield
Device
.
from_string
(
line
.
strip
())
def
_wrap_hours
(
power_on_hours
,
n
):
# SMART self-test lifetime_hours parameter is a 16-bit field that
# wraps around. Try to put it back in the range of the current
# value of power_on_hours, although now we're just making up data
# and this will fail spectacularly in certain circumstances.
if
power_on_hours
<
65536
:
return
n
if
n
<
(
power_on_hours
&
0xffff
):
return
(
power_on_hours
&
0xffff0000
)
+
n
return
n
def
collect_self_test_status
(
device
,
data
):
"""
Extract SMART self-test status from logs.
"""
if
'
ata_smart_self_test_log
'
not
in
data
or
\
'
table
'
not
in
data
[
'
ata_smart_self_test_log
'
][
'
standard
'
]:
return
power_on_hours
=
data
[
'
power_on_time
'
][
'
hours
'
]
# Attempt to extract the most recent self test status by type.
most_recent_test_by_type
=
{}
for
test
in
data
[
'
ata_smart_self_test_log
'
][
'
standard
'
][
'
table
'
]:
...
...
@@ -208,7 +222,8 @@ def collect_self_test_status(device, data):
labels
=
{
'
test
'
:
to_label_value
(
test
[
'
type
'
][
'
string
'
])}
labels
.
update
(
device
.
labels
)
yield
Gauge
(
'
self_test_status
'
,
labels
,
test
[
'
status
'
][
'
passed
'
])
yield
Gauge
(
'
self_test_hours
'
,
labels
,
test
[
'
lifetime_hours
'
])
yield
Gauge
(
'
self_test_hours
'
,
labels
,
_wrap_hours
(
power_on_hours
,
test
[
'
lifetime_hours
'
]))
def
collect_ata_attributes
(
device
,
data
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment