Skip to content
Draft
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
11 changes: 10 additions & 1 deletion plugins/inputs/smartctl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ plugin ordering. See [CONFIGURATION.md][CONFIGURATION.md] for more details.
## * idle: check the device unless it is in sleep, standby, or idle mode
# nocheck = "standby"

## Metric version changes the naming of tags in the smartctl_attributes
## outputs. Currently "smartctl_attribute" metrics include the attribute
## name in the "name" tag, and the associated device is not in any tag,
## making it harder to associate them to the "smartctl" metrics.
## metric_version = 2 will use the "name" tag for the the device name,
## and a new "attribute" tag for the attribute name.
metric_version = 1

## Timeout for the cli command to complete
# timeout = "30s"
```
Expand Down Expand Up @@ -113,7 +121,8 @@ having issues.
- smartctl_attributes
- tags
- model (model name of the storage device)
- name (name of the attribute)
- name (name of the attribute - or the device id if selected by `metric_version=2`)
- attribute (name of the attribute - if selected by `metric_version=2`)
- serial (serial number of the device)
- type (device type like SATA etc)
- wwn (world wide number of the device)
Expand Down
8 changes: 8 additions & 0 deletions plugins/inputs/smartctl/sample.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@
## * idle: check the device unless it is in sleep, standby, or idle mode
# nocheck = "standby"

## Metric version changes the naming of tags in the smartctl_attributes
## outputs. Currently "smartctl_attribute" metrics include the attribute
## name in the "name" tag, and the associated device is not in any tag,
## making it harder to associate them to the "smartctl" metrics.
## metric_version = 2 will use the "name" tag for the the device name,
## and a new "attribute" tag for the attribute name.
# metric_version = 1

## Timeout for the cli command to complete
# timeout = "30s"
1 change: 1 addition & 0 deletions plugins/inputs/smartctl/smartctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type Smartctl struct {
Timeout config.Duration `toml:"timeout"`
DevicesInclude []string `toml:"devices_include"`
DevicesExclude []string `toml:"devices_exclude"`
MetricVersion int `toml:"metric_version"`
Log telegraf.Logger `toml:"-"`

deviceFilter filter.Filter
Expand Down
7 changes: 6 additions & 1 deletion plugins/inputs/smartctl/smartctl_device.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,12 @@ func (s *Smartctl) scanDevice(acc telegraf.Accumulator, deviceName, deviceType s
for k, v := range tags {
attributeTags[k] = v
}
attributeTags["name"] = attribute.Name

if s.MetricVersion == 2 {
attributeTags["attribute"] = attribute.Name
} else {
attributeTags["name"] = attribute.Name // overwrite device name
}

fields := map[string]interface{}{
"raw_value": attribute.Raw.Value,
Expand Down
Loading