Skip to content
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

feat(inputs.smart): Add Power on Hours and Cycle Count #16230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions plugins/inputs/smart/smart.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ var (
"1": "read_error_rate",
"5": "reallocated_sectors_count",
"7": "seek_error_rate",
"9": "power_on_hours",
"12": "power_cycle_count",
"10": "spin_retry_count",
"184": "end_to_end_error",
"187": "uncorrectable_errors",
Expand Down
14 changes: 8 additions & 6 deletions plugins/inputs/smart/smart_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestGatherAttributes(t *testing.T) {
err := s.Gather(&acc)

require.NoError(t, err)
require.Equal(t, 68, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, 70, acc.NFields(), "Wrong number of fields gathered")

for _, test := range testsAda0Attributes {
acc.AssertContainsTaggedFields(t, "smart_attribute", test.fields, test.tags)
Expand Down Expand Up @@ -172,7 +172,7 @@ func TestGatherNoAttributes(t *testing.T) {
err := s.Gather(&acc)

require.NoError(t, err)
require.Equal(t, 11, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, 13, acc.NFields(), "Wrong number of fields gathered")
acc.AssertDoesNotContainMeasurement(t, "smart_attribute")

for _, test := range testsAda0Device {
Expand Down Expand Up @@ -213,7 +213,7 @@ func TestGatherSATAInfo(t *testing.T) {
wg.Add(1)

sampleSmart.gatherDisk(acc, "", wg)
require.Equal(t, 106, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, 108, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, uint64(20), acc.NMetrics(), "Wrong number of metrics gathered")
}

Expand All @@ -229,7 +229,7 @@ func TestGatherSATAInfo65(t *testing.T) {

wg.Add(1)
sampleSmart.gatherDisk(acc, "", wg)
require.Equal(t, 96, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, 98, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, uint64(18), acc.NMetrics(), "Wrong number of metrics gathered")
}

Expand Down Expand Up @@ -294,7 +294,7 @@ func TestGatherSSD(t *testing.T) {

wg.Add(1)
sampleSmart.gatherDisk(acc, "", wg)
require.Equal(t, 110, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, 112, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, uint64(26), acc.NMetrics(), "Wrong number of metrics gathered")
}

Expand All @@ -310,7 +310,7 @@ func TestGatherSSDRaid(t *testing.T) {

wg.Add(1)
sampleSmart.gatherDisk(acc, "", wg)
require.Equal(t, 77, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, 79, acc.NFields(), "Wrong number of fields gathered")
require.Equal(t, uint64(15), acc.NMetrics(), "Wrong number of metrics gathered")
}

Expand Down Expand Up @@ -1492,6 +1492,8 @@ var (
"wear_leveling_count": int64(185),
"pending_sector_count": int64(0),
"reallocated_sectors_count": int64(0),
"power_cycle_count": int64(14879),
"power_on_hours": int64(2988),
},
map[string]string{
"device": "ada0",
Expand Down
Loading