smartctl

package
v1.32.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 12 Imported by: 0

README

smartctl JSON Input Plugin

Get metrics using the command line utility smartctl for S.M.A.R.T. (Self-Monitoring, Analysis and Reporting Technology) storage devices. SMART is a monitoring system included in computer hard disk drives (HDDs), solid-state drives (SSDs), and nVME drives that detects and reports on various indicators of drive reliability, with the intent of enabling the anticipation of hardware failures.

This version of the plugin requires support of the JSON flag from the smartctl command. This flag was added in 7.0 (2019) and further enhanced in subsequent releases.

See smartmontools (https://www.smartmontools.org/) for more information.

smart vs smartctl

The smartctl plugin is an alternative to the smart plugin. The biggest difference is that the smart plugin can also call nvmectl to collect additional details about NVMe devices as well as some vendor specific device information.

This plugin will also require a version of the smartctl command that supports JSON output versus the smart plugin will parse the raw output.

Global configuration options

In addition to the plugin-specific configuration settings, plugins support additional global and plugin configuration settings. These settings are used to modify metrics, tags, and field or create aliases and configure ordering, etc. See the CONFIGURATION.md for more details.

Configuration

# Read metrics from SMART storage devices using smartclt's JSON output
[[inputs.smartctl]]
    ## Optionally specify the path to the smartctl executable
    # path = "/usr/sbin/smartctl"

    ## Use sudo
    ## On most platforms used, smartctl requires root access. Setting 'use_sudo'
    ## to true will make use of sudo to run smartctl. Sudo must be configured to
    ## allow the telegraf user to run smartctl without a password.
    # use_sudo = false

    ## Devices to include or exclude
    ## By default, the plugin will use all devices found in the output of
    ## `smartctl --scan-open`. Only one option is allowed at a time. If set, include
    ## sets the specific devices to scan, while exclude omits specific devices.
    # devices_include = []
    # devices_exclude = []

    ## Skip checking disks in specified power mode
    ## Defaults to "standby" to not wake up disks that have stopped rotating.
    ## For full details on the options here, see the --nocheck section in the
    ## smartctl man page. Choose from:
    ##   * never: always check the device
    ##   * sleep: check the device unless it is in sleep mode
    ##   * standby: check the device unless it is in sleep or standby mode
    ##   * idle: check the device unless it is in sleep, standby, or idle mode
    # nocheck = "standby"

    ## Timeout for the cli command to complete
    # timeout = "30s"

Permissions

It is important to note that this plugin references smartctl, which may require additional permissions to execute successfully. Depending on the user/group permissions of the telegraf user executing this plugin, users may need to use sudo.

Users need the following in the Telegraf config:

[[inputs.smart_json]]
  use_sudo = true

And to update the /etc/sudoers file to allow running smartctl:

$ visudo
# Add the following lines:
Cmnd_Alias SMARTCTL = /usr/sbin/smartctl
telegraf  ALL=(ALL) NOPASSWD: SMARTCTL
Defaults!SMARTCTL !logfile, !syslog, !pam_session

Debugging Issues

This plugin uses the following commands to determine devices and collect metrics:

  • smartctl --json --scan-open
  • smartctl --json --all $DEVICE --device $TYPE --nocheck=$NOCHECK

Please include the output of the above two commands for all devices that are having issues.

Metrics

Example Output

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Smartctl

type Smartctl struct {
	Path           string          `toml:"path"`
	NoCheck        string          `toml:"no_check"`
	UseSudo        bool            `toml:"use_sudo"`
	Timeout        config.Duration `toml:"timeout"`
	DevicesInclude []string        `toml:"devices_include"`
	DevicesExclude []string        `toml:"devices_exclude"`
	Log            telegraf.Logger `toml:"-"`
	// contains filtered or unexported fields
}

func (*Smartctl) Gather

func (s *Smartctl) Gather(acc telegraf.Accumulator) error

func (*Smartctl) Init

func (s *Smartctl) Init() error

func (*Smartctl) SampleConfig

func (*Smartctl) SampleConfig() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL