diff --git a/README.md b/README.md new file mode 100644 index 0000000..83350dc --- /dev/null +++ b/README.md @@ -0,0 +1,178 @@ +# Graphite S.M.A.R.T. Exporter + +_Monitors drive's S.M.A.R.T. attributes and periodically sends them to a Graphite compatible server as tagged metrics_ + +This script was conceived to be an addon to [TrueNAS's](https://www.truenas.com/) own metrics system using [Graphite](https://graphiteapp.org/). The goal of this script was to run out-of-the-box on a TrueNAS SCALE and provide detailed S.M.A.R.T. metrics for all S.M.A.R.T. capable devices in the system. + +It sends plain-text tagged Graphite metrics, which are compatible with the [Prometheus Graphite Exporter](https://github.com/prometheus/graphite_exporter) out-of-the-box. No configuration is necessary in Graphite Exporter, since it supports tagged metrics. To get all of TrueNAS' metrics into Prometheus, Supporterino's [Graphite Mapping File for Prometheus Graphite Exporter](https://github.com/Supporterino/truenas-graphite-to-prometheus) is very helpful. + +If a TrueNAS system is already monitored, a Graphite compatible receiver endpoint is available as well, so this script plugs right into that endpoint. + +Other solutions to get S.M.A.R.T. metrics from a system exist, such as [smartctl_exporter](https://github.com/prometheus-community/smartctl_exporter) or [prometheus-smartctl](https://github.com/matusnovak/prometheus-smartctl), but these would either need to be run in a privileged container using TrueNAS SCALE's app system (`smartctl_exporter`) or need additional python modules not available on a TrueNAS installation (`prometheus-smartctl`). With TrueNAS being an appliance (and moving to a read-only file system with Dragonfish release), installing python modules is not a viable option. + +__Requirements:__ + - [bash](https://www.gnu.org/software/bash/) + - [smartctl 7.0](https://www.smartmontools.org/) + - [jq](https://jqlang.github.io/jq/) (Developed and tested with v1.6, might work with previous versions) + +This script uses `smartctl`'s json output mode, which was introduced with version `7.0`, hence the requirement. + +Even though this script was developed with TrueNAS SCALE in mind, and this documentation mentions use cases related to this scenario in special, it should be able to run on any machine providing the above prerequisites. + +Tested on: + - TrueNAS SCALE 23.10.1 + +Might/should work on TrueNAS CORE, test results are welcome! + +## Key Features + - [Run at startup and send metrics with customizable frequency](#set-up-script-to-run-at-truenas-startup-with-custom-frequency) + - [Tags to make metrics resilient against device name changes after reboots](#exported-metrics-and-tags) + - [Continue to send last known metrics for devices in STANDBY](#continue-to-send-last-known-metrics-for-devices-in-standby) + - [Special metrics for device's power state](#exported-metrics-and-tags) + - [Manually specify devices to monitor](#manually-specifying-devices-to-monitor) + - [Manually specify device types](#manually-specify-device-types) + - [Logging](#logging) + +## Disclaimer + +This script was heavily inspired by ngandrass's [TrueNAS Spindown Timer](https://github.com/ngandrass/truenas-spindown-timer). In fact, it was developed to be used in conjunction with the `truenas-spindown-timer` script, since periodic S.M.A.R.T. queries will prevent a device from spinning down on its own. With `truenas-spindown-timer`, drives will still spin down and not be disturbed by this script. + +One of the main motivations for the development of this script was to gather statistics on how often drives are getting spun down and woken up with a specific usage profile to determine whether disk spindown is worth the potential shortening of disk life vs. energy consumption savings. + +## Usage +``` +Graphite S.M.A.R.T. exporter version 1.0.0 +Usage: + ./graphite-smart-exporter.sh [-h] -d [-p] -n [-f ] [-c] [-m ] [-t ] [-v] [-q] [-l ] [-s ] + +Gathers S.M.A.R.T. data about all S.M.A.R.T. capable drives in the system +and sends them as tagged metrics to a Graphite server. + +Options: + -d DESTINATION : The destnation IP address or host name under which the Graphite + server is reachable. + -p PORT : The port the Graphite server is listening on for the plaintext protocol. + -n HOSTNAME : The host name to set for the metrics' 'instance' tag. + -f FREQUENCY : Frequency metrics are gathered and sent to Graphite with in seconds + (default: 300) + -l : Name of the log file to log into. File logging is only enabled if a file name is provided. (default: empty) + -c : Continue sending last known/stale data if a drive is in standby/spun down. If a drive is spun down, S.M.A.R.T. attributes + cannot be read without waking it up. If this option is set, the script continues to send the last known S.M.A.R.T. + metrics for a drive that is spun down to prevent gaps in data. + Otherwise no metrics are sent until the drive is awake again. + -m DEVICE : List devices to monitor using this argument, once per drive to minor, e.g. -m /dev/sda -m /dev/sdc + -t DEVICE=TYPE : Manually specify the device type for a device. Use this if smartctl device type autodetection does not work for your case. Does NOT disable device discovery. Example: -t /dev/sda=nvme + -s SMART_TEMP_FILE_NAME : Name of the temp file the S.M.A.R.T. output is written to during each cycle the script is running. + Explicitly set if you plan on running multiple instances of this script to prevent collisions. (default: smart_output.json) + -q : Quiet mode. Outputs are suppressed set. Can not be set if -v is set. + -v : Verbose mode. Prints additional information during execution. File logging is only enabled in verbose mode. Can not be set if -q is set. + -h : Print this help message. +Example usage: +./graphite-smart-exporter.sh -d graphite.mydomain.com -n myhost +./graphite-smart-exporter.sh -d graphite.mydomain.com -p 9198 -n myhost -f 600 +./graphite-smart-exporter.sh -d graphite.mydomain.com -n myhost -f 600 -c -m /dev/sda -m /dev/sdc -t /dev/sdc=sat +``` + +## Set up script to run at TrueNAS startup with custom frequency +To automatically run the script after startup, use TrueNAS' [Init/Shutdown Scripts](https://www.truenas.com/docs/scale/scaleuireference/systemsettings/advancedsettingsscreen/#init/shutdown-scripts-widget) feature. +Download the script onto your machine. In your TrueNAS UI, navigate to `System Settings -> Advanced -> Init/Shutdown Scripts` and create a new script with the following settings: + - __Description:__ `Graphite SMART Exporter` + - __Type:__ `Command` + - __Command:__ `sudo /path/to/script/graphite-smart-exporter.sh -d graphite.mydomain.com -n myhost -f 60` + - __When:__ `Post Init` + +![Init Script Settings](images/init_script_setup.png) + +Since `smartctl` is only available for root, the script must be executed with `sudo`. +The command above will send S.M.A.R.T. metrics to your Graphite instance every 60 seconds. + +## Exported Metrics and Tags + +At the moment, the script supports metrics for `sat` and `nvme` type of devices. +(If you need additional device types supported, [open an issue] and append an example output of `smartctl --json=c -a`.) +See [graphite_export.md](example_data/graphite_export.md) for a sample of this script's exported metrics. + +### Metrics +The script will export the following metrics: +| Metric Name | Device Types | Description | +| :--------------------------| :----------- | :------------ | +| `smart_attribute` | `sat` | Standard ATA S.M.A.R.T. attribute | +| `smart_nvme_attribute` | `nvme` | NVME S.M.A.R.T Health Information | +| `smart_device_temperature` | all | Device Temperature in °C | +| `smart_power_cycle_count` | all | Number of count of full power on/off cycles | +| `smart_power_on_time_hours`| all | Number of hours the device has been powered | +| `smart_power_status` | all | Indicator whether the device is active or in standby/spun down | +| `smart_status_passed` | all | Indicating whether the latest S.M.A.R.T. test has passed | + +The following tags/labels are added to the metrics: +### Common Tags +| Tag Name | Description | +| :--------------------------| :------------ | +| `model_name` | The device's model name (if present), e.g. `HGST_HUH721010ALE600` | +| `model_family` | The device's model family (if present), e.g. `HGST_Ultrastar_He10`| +| `serial_number` | The device's serial number, e.g. `1EHXXXXX`; can be used make sure a certain metric always refers to the same phyiscal device if logical device names change during reboots | +| `firmware_version` | The firmware version reported by the device, e.g. `LHGNT384`| +| `user_capacity_bytes` | The drive's capacity in bytes, e.g. `10000831348736` | +| `device_name` | The shortened logical device name, e.g. `sda`; might change during reboots | +| `device_type` | The device type, e.g. `sat` | +| `instance` | The host name passed to the script using `-n` | + +### NVME Specific Tags +`smart_nvme_attribute` metrics have these additional tags: +| Tag Name | Description | +| :--------------------------| :------------ | +| `value_type` | Fixed to `raw` | +| `attribute_name` | Name of the reported NVME Health Information, e.g. `available_spare` | + +### SAT Specific Tags +`smart_attribute` metrics have these additional tags: +| Tag Name | Description | +| :--------------------------| :------------ | +| `value_type` | One of `value`, `worst`, `thresh` or `raw` | +| `attribute_name` | Name of the reported ATA S.M.A.R.T. attribute, e.g. `Start_Stop_Count` | +| `attribute_id` | Unique ID of the S.M.A.R.T. attribute, e.g. `4` | + +### Limitations for tag values +The [Graphite Documentation on tagged metrics](https://graphite.readthedocs.io/en/latest/tags.html) reads the following about tag values: +> Tag values must also have a length >= 1, they may contain any ascii characters except `;` and the first character must not be `~`. + +For values that might not always exist (such as `model_name` or `model_family`) that means that the whole tag cannot be added if the value is empty. +Even though the definition for allowed tag value characters implies that a whitespace is allowed, whitespaces in tag values seem to break some Graphite servers such as the Prometheus Graphite Exporter. This is why this script will replace blanks ` ` in tag values with underscores `_`. + +## Continue to send last known metrics for devices in STANDBY + +If a device is in standby / spun down, querying S.M.A.R.T. attributes would wake it up, which this script will not do. On the other hand this means there are no metrics available for disks that are in standby. + +The script offers the argument `-c`. If that argument is set, it will continue to send the last queried metrics for a device in standby to prevent gaps in the metric time series. The only metric that will be updated is `smart_power_state` (which will reflect the standby state by being `0`). +⚠️ Be aware that this has the side effect of continuous metrics such as `smart_device_temp` or `smart_power_on_hours` to show sudden jumps in graphs when the updated values are sent after the device has woken up again. + + +## Manually specifying devices to monitor + +By default, the script will scan for all S.M.A.R.T. capable device in the system at startup and send metrics for all these devices. If only a specific subset of devices should be monitored, these devices may be passed to the script with the argument `-m`, specifying the argument once per device to monitor. +The following example will only monitor devices `/dev/sda` and `/dev/sdc` and will not scan for other devices: +```bash +./graphite-smart-exporter.sh -d graphite.mydomain.com -n myhost -m /dev/sda -m /dev/sdc +``` + +## Manually specify device types + +`smartctl` will try to guess the correct device type when querying a specific device. However, it might not get it right for all devices, which might result in wrong/missing output. +To manually force the script to use a specific device type for a certain device, specify it using the arugment `-t` in the form `=`, once per device. +The following example will only monitor devices `/dev/sda` and `/dev/sdc`, but force `/dev/sdc` to be treated as `sat` type device: +```bash +./graphite-smart-exporter.sh -d graphite.mydomain.com -n myhost -m /dev/sda -m /dev/sdc -t /dev/sdc=sat +``` + +Note that specifying `-t` alone without `-m` will not disable scanning for devices, but will honor the device type for the specified devices. + +## Logging + +The script uses `logfmt` as a logging format and supports normal logging to console, logging to a file and no log output at all: + - pass no additional arguments to only use normal log output on console + - pass `-v` to enable debug log output + - pass `-l graphite_smart_exporter.log` to enable logging to the `graphite_smart_exporter.log` file using the specified verbosity level + - pass `-q` to disable all logging + +Note that `-v` and `-q` cannot be set at the same time. + diff --git a/example_data/graphite_export.md b/example_data/graphite_export.md new file mode 100644 index 0000000..c76a47d --- /dev/null +++ b/example_data/graphite_export.md @@ -0,0 +1,103 @@ +``` +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=available_spare 100 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=available_spare_threshold 10 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=controller_busy_time 4102 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=critical_comp_time 0 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=critical_warning 0 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=data_units_read 6234286 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=data_units_written 17655889 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=host_reads 40996899 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=host_writes 320946707 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=media_errors 0 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=num_err_log_entries 0 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=percentage_used 0 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=power_cycles 468 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=power_on_hours 510 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=temperature 47 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=unsafe_shutdowns 54 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=warning_temp_time 0 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=temperature_sensor_0 47 1710063513 +smart_nvme_attribute;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com;value_type=raw;attribute_name=temperature_sensor_1 66 1710063513 +smart_device_temperature;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com 47 1710063513 +smart_power_cycle_count;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com 468 1710063513 +smart_power_on_time_hours;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com 510 1710063513 +smart_status_passed;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com 1 1710063513 +smart_power_status;model_name=Samsung_SSD_980_PRO_2TB;serial_number=S777NN0W111111Y;firmware_version=5B2QGXA7;user_capacity_bytes=2000398934016;device_name=nvme0;device_type=nvme;instance=myhost.mydomain.com 1 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=1;attribute_name=Raw_Read_Error_Rate 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=1;attribute_name=Raw_Read_Error_Rate 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=1;attribute_name=Raw_Read_Error_Rate 16 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=1;attribute_name=Raw_Read_Error_Rate 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=2;attribute_name=Throughput_Performance 134 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=2;attribute_name=Throughput_Performance 96 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=2;attribute_name=Throughput_Performance 54 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=2;attribute_name=Throughput_Performance 134 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=3;attribute_name=Spin_Up_Time 148 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=3;attribute_name=Spin_Up_Time 34388902332 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=3;attribute_name=Spin_Up_Time 24 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=3;attribute_name=Spin_Up_Time 148 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=4;attribute_name=Start_Stop_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=4;attribute_name=Start_Stop_Count 816 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=4;attribute_name=Start_Stop_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=4;attribute_name=Start_Stop_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=5;attribute_name=Reallocated_Sector_Ct 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=5;attribute_name=Reallocated_Sector_Ct 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=5;attribute_name=Reallocated_Sector_Ct 5 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=5;attribute_name=Reallocated_Sector_Ct 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=7;attribute_name=Seek_Error_Rate 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=7;attribute_name=Seek_Error_Rate 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=7;attribute_name=Seek_Error_Rate 67 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=7;attribute_name=Seek_Error_Rate 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=8;attribute_name=Seek_Time_Performance 128 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=8;attribute_name=Seek_Time_Performance 18 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=8;attribute_name=Seek_Time_Performance 20 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=8;attribute_name=Seek_Time_Performance 128 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=9;attribute_name=Power_On_Hours 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=9;attribute_name=Power_On_Hours 6922 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=9;attribute_name=Power_On_Hours 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=9;attribute_name=Power_On_Hours 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=10;attribute_name=Spin_Retry_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=10;attribute_name=Spin_Retry_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=10;attribute_name=Spin_Retry_Count 60 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=10;attribute_name=Spin_Retry_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=12;attribute_name=Power_Cycle_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=12;attribute_name=Power_Cycle_Count 710 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=12;attribute_name=Power_Cycle_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=12;attribute_name=Power_Cycle_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=22;attribute_name=Helium_Level 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=22;attribute_name=Helium_Level 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=22;attribute_name=Helium_Level 25 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=22;attribute_name=Helium_Level 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=192;attribute_name=Power-Off_Retract_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=192;attribute_name=Power-Off_Retract_Count 956 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=192;attribute_name=Power-Off_Retract_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=192;attribute_name=Power-Off_Retract_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=193;attribute_name=Load_Cycle_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=193;attribute_name=Load_Cycle_Count 956 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=193;attribute_name=Load_Cycle_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=193;attribute_name=Load_Cycle_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=194;attribute_name=Temperature_Celsius 171 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=194;attribute_name=Temperature_Celsius 335008366627 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=194;attribute_name=Temperature_Celsius 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=194;attribute_name=Temperature_Celsius 171 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=196;attribute_name=Reallocated_Event_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=196;attribute_name=Reallocated_Event_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=196;attribute_name=Reallocated_Event_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=196;attribute_name=Reallocated_Event_Count 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=197;attribute_name=Current_Pending_Sector 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=197;attribute_name=Current_Pending_Sector 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=197;attribute_name=Current_Pending_Sector 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=197;attribute_name=Current_Pending_Sector 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=198;attribute_name=Offline_Uncorrectable 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=198;attribute_name=Offline_Uncorrectable 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=198;attribute_name=Offline_Uncorrectable 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=198;attribute_name=Offline_Uncorrectable 100 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=value;attribute_id=199;attribute_name=UDMA_CRC_Error_Count 200 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=raw;attribute_id=199;attribute_name=UDMA_CRC_Error_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=thresh;attribute_id=199;attribute_name=UDMA_CRC_Error_Count 0 1710063513 +smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com;value_type=worst;attribute_id=199;attribute_name=UDMA_CRC_Error_Count 200 1710063513 +smart_device_temperature;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com 35 1710063513 +smart_power_cycle_count;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com 710 1710063513 +smart_power_on_time_hours;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com 6922 1710063513 +smart_status_passed;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com 1 1710063513 +smart_power_status;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1EHXXXXX;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=myhost.mydomain.com 1 1710063513 +``` \ No newline at end of file diff --git a/example_data/smartctl/smartctl_device_standby.json b/example_data/smartctl/smartctl_device_standby.json new file mode 100644 index 0000000..ba1a18b --- /dev/null +++ b/example_data/smartctl/smartctl_device_standby.json @@ -0,0 +1,40 @@ +{ + "json_format_version": [ + 1, + 0 + ], + "smartctl": { + "version": [ + 7, + 3 + ], + "svn_revision": "5338", + "platform_info": "x86_64-linux-6.1.63-production+truenas", + "build_info": "(local build)", + "argv": [ + "smartctl", + "--json=c", + "-a", + "-n", + "standby", + "/dev/sdj" + ], + "messages": [ + { + "string": "Device is in STANDBY mode, exit(2)", + "severity": "information" + } + ], + "exit_status": 2 + }, + "local_time": { + "time_t": 1708982317, + "asctime": "Mon Feb 26 22:18:37 2024 CET" + }, + "device": { + "name": "/dev/sdj", + "info_name": "/dev/sdj [SAT]", + "type": "sat", + "protocol": "ATA" + } +} \ No newline at end of file diff --git a/example_data/smartctl/smartctl_nvme.json b/example_data/smartctl/smartctl_nvme.json new file mode 100644 index 0000000..67c60db --- /dev/null +++ b/example_data/smartctl/smartctl_nvme.json @@ -0,0 +1,115 @@ +{ + "json_format_version": [ + 1, + 0 + ], + "smartctl": { + "version": [ + 7, + 3 + ], + "svn_revision": "5338", + "platform_info": "x86_64-linux-6.1.63-production+truenas", + "build_info": "(local build)", + "argv": [ + "smartctl", + "-a", + "--json=c", + "/dev/nvme0" + ], + "exit_status": 0 + }, + "local_time": { + "time_t": 1709844021, + "asctime": "Thu Mar 7 21:40:21 2024 CET" + }, + "device": { + "name": "/dev/nvme0", + "info_name": "/dev/nvme0", + "type": "nvme", + "protocol": "NVMe" + }, + "model_name": "Samsung SSD 980 PRO 2TB", + "serial_number": "S777NN0W111111Y", + "firmware_version": "5B2QGXA7", + "nvme_pci_vendor": { + "id": 5197, + "subsystem_id": 5197 + }, + "nvme_ieee_oui_identifier": 9528, + "nvme_total_capacity": 2000398934016, + "nvme_unallocated_capacity": 0, + "nvme_controller_id": 6, + "nvme_version": { + "string": "1.3", + "value": 66304 + }, + "nvme_number_of_namespaces": 1, + "nvme_namespaces": [ + { + "id": 1, + "size": { + "blocks": 3907029168, + "bytes": 2000398934016 + }, + "capacity": { + "blocks": 3907029168, + "bytes": 2000398934016 + }, + "utilization": { + "blocks": 768213800, + "bytes": 393325465600 + }, + "formatted_lba_size": 512, + "eui64": { + "oui": 9528, + "ext_id": 761042037182 + } + } + ], + "user_capacity": { + "blocks": 3907029168, + "bytes": 2000398934016 + }, + "logical_block_size": 512, + "smart_support": { + "available": true, + "enabled": true + }, + "smart_status": { + "passed": true, + "nvme": { + "value": 0 + } + }, + "nvme_smart_health_information_log": { + "critical_warning": 0, + "temperature": 38, + "available_spare": 100, + "available_spare_threshold": 10, + "percentage_used": 0, + "data_units_read": 6032641, + "data_units_written": 17235703, + "host_reads": 39357604, + "host_writes": 315507959, + "controller_busy_time": 3972, + "power_cycles": 465, + "power_on_hours": 499, + "unsafe_shutdowns": 54, + "media_errors": 0, + "num_err_log_entries": 0, + "warning_temp_time": 0, + "critical_comp_time": 0, + "temperature_sensors": [ + 38, + 39 + ] + }, + "temperature": { + "current": 38 + }, + "power_cycle_count": 465, + "power_on_time": { + "hours": 499 + } +} \ No newline at end of file diff --git a/example_data/smartctl/smartctl_sat_hdd.json b/example_data/smartctl/smartctl_sat_hdd.json new file mode 100644 index 0000000..4fd5f4f --- /dev/null +++ b/example_data/smartctl/smartctl_sat_hdd.json @@ -0,0 +1,856 @@ +{ + "json_format_version": [ + 1, + 0 + ], + "smartctl": { + "version": [ + 7, + 3 + ], + "svn_revision": "5338", + "platform_info": "x86_64-linux-6.1.63-production+truenas", + "build_info": "(local build)", + "argv": [ + "smartctl", + "--json=c", + "-a", + "/dev/sda" + ], + "drive_database_version": { + "string": "7.3/5319" + }, + "exit_status": 0 + }, + "local_time": { + "time_t": 1708886535, + "asctime": "Sun Feb 25 19:42:15 2024 CET" + }, + "device": { + "name": "/dev/sda", + "info_name": "/dev/sda [SAT]", + "type": "sat", + "protocol": "ATA" + }, + "model_family": "Western Digital Ultrastar DC HC550", + "model_name": "WDC WUH721818ALE6L4", + "serial_number": "6PPPP8XX", + "wwn": { + "naa": 5, + "oui": 3274, + "id": 12411285045 + }, + "firmware_version": "PCGNW680", + "user_capacity": { + "blocks": 35156656128, + "bytes": 18000207937536 + }, + "logical_block_size": 512, + "physical_block_size": 4096, + "rotation_rate": 7200, + "form_factor": { + "ata_value": 2, + "name": "3.5 inches" + }, + "trim": { + "supported": false + }, + "in_smartctl_database": true, + "ata_version": { + "string": "ACS-4 published, ANSI INCITS 529-2018", + "major_value": 4092, + "minor_value": 156 + }, + "sata_version": { + "string": "SATA 3.3", + "value": 511 + }, + "interface_speed": { + "max": { + "sata_value": 14, + "string": "6.0 Gb/s", + "units_per_second": 60, + "bits_per_unit": 100000000 + }, + "current": { + "sata_value": 3, + "string": "6.0 Gb/s", + "units_per_second": 60, + "bits_per_unit": 100000000 + } + }, + "smart_support": { + "available": true, + "enabled": true + }, + "smart_status": { + "passed": true + }, + "ata_smart_data": { + "offline_data_collection": { + "status": { + "value": 128, + "string": "was never started" + }, + "completion_seconds": 101 + }, + "self_test": { + "status": { + "value": 0, + "string": "completed without error", + "passed": true + }, + "polling_minutes": { + "short": 2, + "extended": 2016 + } + }, + "capabilities": { + "values": [ + 91, + 3 + ], + "exec_offline_immediate_supported": true, + "offline_is_aborted_upon_new_cmd": false, + "offline_surface_scan_supported": true, + "self_tests_supported": true, + "conveyance_self_test_supported": false, + "selective_self_test_supported": true, + "attribute_autosave_enabled": true, + "error_logging_supported": true, + "gp_logging_supported": true + } + }, + "ata_sct_capabilities": { + "value": 61, + "error_recovery_control_supported": true, + "feature_control_supported": true, + "data_table_supported": true + }, + "ata_smart_attributes": { + "revision": 16, + "table": [ + { + "id": 1, + "name": "Raw_Read_Error_Rate", + "value": 100, + "worst": 100, + "thresh": 1, + "when_failed": "", + "flags": { + "value": 11, + "string": "PO-R-- ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": true, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 2, + "name": "Throughput_Performance", + "value": 149, + "worst": 149, + "thresh": 54, + "when_failed": "", + "flags": { + "value": 5, + "string": "P-S--- ", + "prefailure": true, + "updated_online": false, + "performance": true, + "error_rate": false, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 44, + "string": "44" + } + }, + { + "id": 3, + "name": "Spin_Up_Time", + "value": 83, + "worst": 83, + "thresh": 1, + "when_failed": "", + "flags": { + "value": 7, + "string": "POS--- ", + "prefailure": true, + "updated_online": true, + "performance": true, + "error_rate": false, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 30088102243, + "string": "355 (Average 356)" + } + }, + { + "id": 4, + "name": "Start_Stop_Count", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 18, + "string": "-O--C- ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": false + }, + "raw": { + "value": 339, + "string": "339" + } + }, + { + "id": 5, + "name": "Reallocated_Sector_Ct", + "value": 100, + "worst": 100, + "thresh": 1, + "when_failed": "", + "flags": { + "value": 51, + "string": "PO--CK ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 7, + "name": "Seek_Error_Rate", + "value": 100, + "worst": 100, + "thresh": 1, + "when_failed": "", + "flags": { + "value": 11, + "string": "PO-R-- ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": true, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 8, + "name": "Seek_Time_Performance", + "value": 140, + "worst": 140, + "thresh": 20, + "when_failed": "", + "flags": { + "value": 5, + "string": "P-S--- ", + "prefailure": true, + "updated_online": false, + "performance": true, + "error_rate": false, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 15, + "string": "15" + } + }, + { + "id": 9, + "name": "Power_On_Hours", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 18, + "string": "-O--C- ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": false + }, + "raw": { + "value": 2915, + "string": "2915" + } + }, + { + "id": 10, + "name": "Spin_Retry_Count", + "value": 100, + "worst": 100, + "thresh": 1, + "when_failed": "", + "flags": { + "value": 19, + "string": "PO--C- ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 12, + "name": "Power_Cycle_Count", + "value": 97, + "worst": 97, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 225, + "string": "225" + } + }, + { + "id": 22, + "name": "Helium_Level", + "value": 100, + "worst": 100, + "thresh": 25, + "when_failed": "", + "flags": { + "value": 35, + "string": "PO---K ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": true + }, + "raw": { + "value": 100, + "string": "100" + } + }, + { + "id": 192, + "name": "Power-Off_Retract_Count", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 674, + "string": "674" + } + }, + { + "id": 193, + "name": "Load_Cycle_Count", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 18, + "string": "-O--C- ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": false + }, + "raw": { + "value": 674, + "string": "674" + } + }, + { + "id": 194, + "name": "Temperature_Celsius", + "value": 48, + "worst": 48, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 2, + "string": "-O---- ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 253404053549, + "string": "45 (Min/Max 15/59)" + } + }, + { + "id": 196, + "name": "Reallocated_Event_Count", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 197, + "name": "Current_Pending_Sector", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 34, + "string": "-O---K ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 198, + "name": "Offline_Uncorrectable", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 8, + "string": "---R-- ", + "prefailure": false, + "updated_online": false, + "performance": false, + "error_rate": true, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 199, + "name": "UDMA_CRC_Error_Count", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 10, + "string": "-O-R-- ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": true, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + } + ] + }, + "power_on_time": { + "hours": 2915 + }, + "power_cycle_count": 225, + "temperature": { + "current": 45 + }, + "ata_smart_error_log": { + "summary": { + "revision": 1, + "count": 0 + } + }, + "ata_smart_self_test_log": { + "standard": { + "revision": 1, + "table": [ + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2859 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2813 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2776 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2720 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2658 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2603 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2506 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2410 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2370 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2296 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2203 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2131 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2057 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2014 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1958 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1900 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1827 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1766 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1704 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1648 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1568 + } + ], + "count": 21, + "error_count_total": 0, + "error_count_outdated": 0 + } + }, + "ata_smart_selective_self_test_log": { + "revision": 1, + "table": [ + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + }, + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + }, + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + }, + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + }, + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + } + ], + "flags": { + "value": 0, + "remainder_scan_enabled": false + }, + "power_up_scan_resume_minutes": 0 + } +} \ No newline at end of file diff --git a/example_data/smartctl/smartctl_sat_hdd_seagate.json b/example_data/smartctl/smartctl_sat_hdd_seagate.json new file mode 100644 index 0000000..6b248df --- /dev/null +++ b/example_data/smartctl/smartctl_sat_hdd_seagate.json @@ -0,0 +1,943 @@ +{ + "json_format_version": [ + 1, + 0 + ], + "smartctl": { + "version": [ + 7, + 3 + ], + "svn_revision": "5338", + "platform_info": "x86_64-linux-6.1.63-production+truenas", + "build_info": "(local build)", + "argv": [ + "smartctl", + "--json=c", + "-a", + "/dev/sdf" + ], + "drive_database_version": { + "string": "7.3/5319" + }, + "exit_status": 32 + }, + "local_time": { + "time_t": 1710063353, + "asctime": "Sun Mar 10 10:35:53 2024 CET" + }, + "device": { + "name": "/dev/sdf", + "info_name": "/dev/sdf [SAT]", + "type": "sat", + "protocol": "ATA" + }, + "model_family": "Seagate IronWolf", + "model_name": "ST10000VN0004-2GS11L", + "serial_number": "ZJV11HHH", + "wwn": { + "naa": 5, + "oui": 3152, + "id": 2979462163 + }, + "firmware_version": "SC60", + "user_capacity": { + "blocks": 19532873728, + "bytes": 10000831348736 + }, + "logical_block_size": 512, + "physical_block_size": 4096, + "rotation_rate": 7200, + "form_factor": { + "ata_value": 2, + "name": "3.5 inches" + }, + "trim": { + "supported": false + }, + "in_smartctl_database": true, + "ata_version": { + "string": "ACS-3 T13/2161-D revision 5", + "major_value": 2032, + "minor_value": 109 + }, + "sata_version": { + "string": "SATA 3.1", + "value": 127 + }, + "interface_speed": { + "max": { + "sata_value": 14, + "string": "6.0 Gb/s", + "units_per_second": 60, + "bits_per_unit": 100000000 + }, + "current": { + "sata_value": 3, + "string": "6.0 Gb/s", + "units_per_second": 60, + "bits_per_unit": 100000000 + } + }, + "smart_support": { + "available": true, + "enabled": true + }, + "smart_status": { + "passed": true + }, + "ata_smart_data": { + "offline_data_collection": { + "status": { + "value": 130, + "string": "was completed without error", + "passed": true + }, + "completion_seconds": 575 + }, + "self_test": { + "status": { + "value": 0, + "string": "completed without error", + "passed": true + }, + "polling_minutes": { + "short": 1, + "extended": 916, + "conveyance": 2 + } + }, + "capabilities": { + "values": [ + 123, + 3 + ], + "exec_offline_immediate_supported": true, + "offline_is_aborted_upon_new_cmd": false, + "offline_surface_scan_supported": true, + "self_tests_supported": true, + "conveyance_self_test_supported": true, + "selective_self_test_supported": true, + "attribute_autosave_enabled": true, + "error_logging_supported": true, + "gp_logging_supported": true + } + }, + "ata_sct_capabilities": { + "value": 20669, + "error_recovery_control_supported": true, + "feature_control_supported": true, + "data_table_supported": true + }, + "ata_smart_attributes": { + "revision": 10, + "table": [ + { + "id": 1, + "name": "Raw_Read_Error_Rate", + "value": 82, + "worst": 64, + "thresh": 44, + "when_failed": "", + "flags": { + "value": 15, + "string": "POSR-- ", + "prefailure": true, + "updated_online": true, + "performance": true, + "error_rate": true, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 172568138, + "string": "172568138" + } + }, + { + "id": 3, + "name": "Spin_Up_Time", + "value": 88, + "worst": 87, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 3, + "string": "PO---- ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 4, + "name": "Start_Stop_Count", + "value": 99, + "worst": 99, + "thresh": 20, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 1205, + "string": "1205" + } + }, + { + "id": 5, + "name": "Reallocated_Sector_Ct", + "value": 100, + "worst": 100, + "thresh": 10, + "when_failed": "", + "flags": { + "value": 51, + "string": "PO--CK ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 7, + "name": "Seek_Error_Rate", + "value": 90, + "worst": 60, + "thresh": 45, + "when_failed": "", + "flags": { + "value": 15, + "string": "POSR-- ", + "prefailure": true, + "updated_online": true, + "performance": true, + "error_rate": true, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 894084213, + "string": "894084213" + } + }, + { + "id": 9, + "name": "Power_On_Hours", + "value": 84, + "worst": 84, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 14041, + "string": "14041" + } + }, + { + "id": 10, + "name": "Spin_Retry_Count", + "value": 100, + "worst": 100, + "thresh": 97, + "when_failed": "", + "flags": { + "value": 19, + "string": "PO--C- ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 12, + "name": "Power_Cycle_Count", + "value": 99, + "worst": 99, + "thresh": 20, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 1097, + "string": "1097" + } + }, + { + "id": 187, + "name": "Reported_Uncorrect", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 188, + "name": "Command_Timeout", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 190, + "name": "Airflow_Temperature_Cel", + "value": 69, + "worst": 23, + "thresh": 40, + "when_failed": "past", + "flags": { + "value": 34, + "string": "-O---K ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": true + }, + "raw": { + "value": 3629768507423, + "string": "31 (3 77 31 16 0)" + } + }, + { + "id": 192, + "name": "Power-Off_Retract_Count", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 307, + "string": "307" + } + }, + { + "id": 193, + "name": "Load_Cycle_Count", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 1509, + "string": "1509" + } + }, + { + "id": 194, + "name": "Temperature_Celsius", + "value": 31, + "worst": 77, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 34, + "string": "-O---K ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": true + }, + "raw": { + "value": 60129542175, + "string": "31 (0 14 0 0 0)" + } + }, + { + "id": 195, + "name": "Hardware_ECC_Recovered", + "value": 3, + "worst": 1, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 26, + "string": "-O-RC- ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": true, + "event_count": true, + "auto_keep": false + }, + "raw": { + "value": 172568138, + "string": "172568138" + } + }, + { + "id": 197, + "name": "Current_Pending_Sector", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 18, + "string": "-O--C- ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 198, + "name": "Offline_Uncorrectable", + "value": 100, + "worst": 100, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 16, + "string": "----C- ", + "prefailure": false, + "updated_online": false, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": false + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 199, + "name": "UDMA_CRC_Error_Count", + "value": 200, + "worst": 200, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 62, + "string": "-OSRCK ", + "prefailure": false, + "updated_online": true, + "performance": true, + "error_rate": true, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 200, + "name": "Pressure_Limit", + "value": 100, + "worst": 100, + "thresh": 1, + "when_failed": "", + "flags": { + "value": 35, + "string": "PO---K ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 240, + "name": "Head_Flying_Hours", + "value": 100, + "worst": 253, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 0, + "string": "------ ", + "prefailure": false, + "updated_online": false, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 12547476372338180, + "string": "13828h+48m+41.437s" + } + }, + { + "id": 241, + "name": "Total_LBAs_Written", + "value": 100, + "worst": 253, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 0, + "string": "------ ", + "prefailure": false, + "updated_online": false, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 72302030145, + "string": "72302030145" + } + }, + { + "id": 242, + "name": "Total_LBAs_Read", + "value": 100, + "worst": 253, + "thresh": 0, + "when_failed": "", + "flags": { + "value": 0, + "string": "------ ", + "prefailure": false, + "updated_online": false, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": false + }, + "raw": { + "value": 507036166434, + "string": "507036166434" + } + } + ] + }, + "power_on_time": { + "hours": 14041 + }, + "power_cycle_count": 1097, + "temperature": { + "current": 31 + }, + "ata_smart_error_log": { + "summary": { + "revision": 1, + "count": 0 + } + }, + "ata_smart_self_test_log": { + "standard": { + "revision": 1, + "table": [ + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 14001 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13957 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13911 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13849 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13804 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13755 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13710 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13648 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13594 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13497 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13484 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13401 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13347 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13287 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13193 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13122 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 13047 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 11875 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 32, + "string": "Interrupted (host reset)" + }, + "lifetime_hours": 11638 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 32, + "string": "Interrupted (host reset)" + }, + "lifetime_hours": 11616 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 32, + "string": "Interrupted (host reset)" + }, + "lifetime_hours": 11582 + } + ], + "count": 21, + "error_count_total": 0, + "error_count_outdated": 0 + } + }, + "ata_smart_selective_self_test_log": { + "revision": 1, + "table": [ + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + }, + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + }, + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + }, + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + }, + { + "lba_min": 0, + "lba_max": 0, + "status": { + "value": 0, + "string": "Not_testing" + } + } + ], + "flags": { + "value": 0, + "remainder_scan_enabled": false + }, + "power_up_scan_resume_minutes": 0 + } +} \ No newline at end of file diff --git a/example_data/smartctl/smartctl_sat_ssd.json b/example_data/smartctl/smartctl_sat_ssd.json new file mode 100644 index 0000000..0957e0a --- /dev/null +++ b/example_data/smartctl/smartctl_sat_ssd.json @@ -0,0 +1,1066 @@ +{ + "json_format_version": [ + 1, + 0 + ], + "smartctl": { + "version": [ + 7, + 3 + ], + "svn_revision": "5338", + "platform_info": "x86_64-linux-6.1.63-production+truenas", + "build_info": "(local build)", + "argv": [ + "smartctl", + "--json=c", + "-a", + "/dev/sdj" + ], + "drive_database_version": { + "string": "7.3/5319" + }, + "exit_status": 0 + }, + "local_time": { + "time_t": 1708886906, + "asctime": "Sun Feb 25 19:48:26 2024 CET" + }, + "device": { + "name": "/dev/sdj", + "info_name": "/dev/sdj [SAT]", + "type": "sat", + "protocol": "ATA" + }, + "model_name": "HP SSD S700 120GB", + "serial_number": "HASA11111111111", + "firmware_version": "V0919A0", + "user_capacity": { + "blocks": 234441648, + "bytes": 120034123776 + }, + "logical_block_size": 512, + "physical_block_size": 512, + "rotation_rate": 0, + "form_factor": { + "ata_value": 3, + "name": "2.5 inches" + }, + "trim": { + "supported": true, + "deterministic": false, + "zeroed": false + }, + "in_smartctl_database": false, + "ata_version": { + "string": "ACS-2 T13/2015-D revision 3", + "major_value": 1008, + "minor_value": 272 + }, + "sata_version": { + "string": "SATA 3.2", + "value": 255 + }, + "interface_speed": { + "max": { + "sata_value": 14, + "string": "6.0 Gb/s", + "units_per_second": 60, + "bits_per_unit": 100000000 + }, + "current": { + "sata_value": 3, + "string": "6.0 Gb/s", + "units_per_second": 60, + "bits_per_unit": 100000000 + } + }, + "smart_support": { + "available": true, + "enabled": true + }, + "smart_status": { + "passed": true + }, + "ata_smart_data": { + "offline_data_collection": { + "status": { + "value": 0, + "string": "was never started" + }, + "completion_seconds": 120 + }, + "self_test": { + "status": { + "value": 0, + "string": "completed without error", + "passed": true + }, + "polling_minutes": { + "short": 2, + "extended": 10 + } + }, + "capabilities": { + "values": [ + 17, + 2 + ], + "exec_offline_immediate_supported": true, + "offline_is_aborted_upon_new_cmd": false, + "offline_surface_scan_supported": false, + "self_tests_supported": true, + "conveyance_self_test_supported": false, + "selective_self_test_supported": false, + "attribute_autosave_enabled": false, + "error_logging_supported": true, + "gp_logging_supported": true + } + }, + "ata_sct_capabilities": { + "value": 1, + "error_recovery_control_supported": false, + "feature_control_supported": false, + "data_table_supported": false + }, + "ata_smart_attributes": { + "revision": 1, + "table": [ + { + "id": 1, + "name": "Raw_Read_Error_Rate", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 5, + "name": "Reallocated_Sector_Ct", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 9, + "name": "Power_On_Hours", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 2485, + "string": "2485" + } + }, + { + "id": 12, + "name": "Power_Cycle_Count", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 491, + "string": "491" + } + }, + { + "id": 160, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 161, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 51, + "string": "PO--CK ", + "prefailure": true, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 100, + "string": "100" + } + }, + { + "id": 163, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 48, + "string": "48" + } + }, + { + "id": 164, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 11886, + "string": "11886" + } + }, + { + "id": 165, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 39, + "string": "39" + } + }, + { + "id": 166, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 2, + "string": "2" + } + }, + { + "id": 167, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 28, + "string": "28" + } + }, + { + "id": 168, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 5050, + "string": "5050" + } + }, + { + "id": 169, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 100, + "string": "100" + } + }, + { + "id": 175, + "name": "Program_Fail_Count_Chip", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 176, + "name": "Erase_Fail_Count_Chip", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 177, + "name": "Wear_Leveling_Count", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 178, + "name": "Used_Rsvd_Blk_Cnt_Chip", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 181, + "name": "Program_Fail_Cnt_Total", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 182, + "name": "Erase_Fail_Count_Total", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 192, + "name": "Power-Off_Retract_Count", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 179, + "string": "179" + } + }, + { + "id": 194, + "name": "Temperature_Celsius", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 34, + "string": "-O---K ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": false, + "auto_keep": true + }, + "raw": { + "value": 24, + "string": "24" + } + }, + { + "id": 195, + "name": "Hardware_ECC_Recovered", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 196, + "name": "Reallocated_Event_Count", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 197, + "name": "Current_Pending_Sector", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 198, + "name": "Offline_Uncorrectable", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 199, + "name": "UDMA_CRC_Error_Count", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 0, + "string": "0" + } + }, + { + "id": 232, + "name": "Available_Reservd_Space", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 100, + "string": "100" + } + }, + { + "id": 241, + "name": "Total_LBAs_Written", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 48, + "string": "----CK ", + "prefailure": false, + "updated_online": false, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 53293, + "string": "53293" + } + }, + { + "id": 242, + "name": "Total_LBAs_Read", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 48, + "string": "----CK ", + "prefailure": false, + "updated_online": false, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 14181, + "string": "14181" + } + }, + { + "id": 245, + "name": "Unknown_Attribute", + "value": 100, + "worst": 100, + "thresh": 50, + "when_failed": "", + "flags": { + "value": 50, + "string": "-O--CK ", + "prefailure": false, + "updated_online": true, + "performance": false, + "error_rate": false, + "event_count": true, + "auto_keep": true + }, + "raw": { + "value": 85311, + "string": "85311" + } + } + ] + }, + "power_on_time": { + "hours": 2485 + }, + "power_cycle_count": 491, + "temperature": { + "current": 24 + }, + "ata_smart_error_log": { + "summary": { + "revision": 1, + "count": 0 + } + }, + "ata_smart_self_test_log": { + "standard": { + "revision": 1, + "table": [ + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2433 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2391 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2331 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2300 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2242 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2191 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 41, + "string": "Interrupted (host reset)", + "remaining_percent": 90 + }, + "lifetime_hours": 2098 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 2004 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1939 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1893 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1803 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1735 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1665 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1596 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1568 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1515 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1445 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1387 + }, + { + "type": { + "value": 2, + "string": "Extended offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1302 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1274 + }, + { + "type": { + "value": 1, + "string": "Short offline" + }, + "status": { + "value": 0, + "string": "Completed without error", + "passed": true + }, + "lifetime_hours": 1196 + } + ], + "count": 21, + "error_count_total": 0, + "error_count_outdated": 0 + } + } +} \ No newline at end of file diff --git a/graphite_smart_exporter.sh b/graphite_smart_exporter.sh new file mode 100755 index 0000000..79b3d2d --- /dev/null +++ b/graphite_smart_exporter.sh @@ -0,0 +1,430 @@ +#!/usr/bin/env bash + +VERSION=1.0.0 +DESTINATION= # The destination where the Graphite server is reachable +PORT=2003 # The port the Graphite server listens on for the plaintext protocol +FREQUENCY=300 # The frequency data is gathered and sent to graphite in +VERBOSE=0 # Default verbosity level +QUIET=0 # Does not write any output if set +OMIT_DRIVES_IN_STANDBY=1 # Does not send the last known metrics for drives that are in standby +DISABLE_DRIVE_DETECTION=0 # Disable drive detection using smartctl. Only enabled if devices to monitor are supplied as arguments +declare -A DRIVES # Associative array for detected drives, mapping to device type +declare -A DRIVE_COMMON_TAGS # Associative array for storing common drive tags +declare -A METRICS # Associative array keeping track of the metrics for each drive +TEMP_FILE_PREIFX=smartctl_output # Name prefix of the temporary file smartctl output is stored in. jq seems to be more efficient when reading from file vs. getting the input piped to +LOG_FILE="" # Log file name. File logging is only enabled if not empty. +SMART_TEMP_FILE_NAME="smart_output.json" # Name of the temp file SMART output is written to. jq is more efficient when reading input from a file instead of piping the output to it. +METRIC_NAME_VALUE_DELIMITER=">>" # Delimiter used between metric name and value when building metrics +SMART_POWER_STATUS_METRIC_NAME="smart_power_status" # Metric name indicating the power status (active or standby/sleep) + +## +# Prints the help/usage message +## +function print_usage() { + cat << EOF +Graphite S.M.A.R.T. exporter version ${VERSION} +Usage: + $0 [-h] -d [-p] -n [-f ] [-c] [-m ] [-t ] [-v] [-q] [-l ] [-s ] + +Gathers S.M.A.R.T. data about all S.M.A.R.T. capable drives in the system +and sends them as tagged metrics to a Graphite server. + +Options: + -d DESTINATION : The destnation IP address or host name under which the Graphite + server is reachable. + -p PORT : The port the Graphite server is listening on for the plaintext protocol. + -n HOSTNAME : The host name to set for the metrics' 'instance' tag. + -f FREQUENCY : Frequency metrics are gathered and sent to Graphite with in seconds + (default: 300) + -l LOG_FILE : Name of the log file to log into. File logging is only enabled if a file name is provided. (default: empty) + -c : Continue sending last known/stale data if a drive is in standby/spun down. If a drive is spun down, S.M.A.R.T. attributes + cannot be read without waking it up. If this option is set, the script continues to send the last known S.M.A.R.T. + metrics for a drive that is spun down to prevent gaps in data. + Otherwise no metrics are sent until the drive is awake again. + -m DEVICE : List devices to monitor using this argument, once per drive to minor, e.g. -m /dev/sda -m /dev/sdc + -t DEVICE=TYPE : Manually specify the device type for a device. Use this if smartctl device type autodetection does not work for your case. Does NOT disable device discovery. Example: -t /dev/sda=nvme + -s SMART_TEMP_FILE_NAME : Name of the temp file the S.M.A.R.T. output is written to during each cycle the script is running. + Explicitly set if you plan on running multiple instances of this script to prevent collisions. (default: smart_output.json) + -q : Quiet mode. Outputs are suppressed set. Can not be set if -v is set. + -v : Verbose mode. Prints additional information during execution. File logging is only enabled in verbose mode. Can not be set if -q is set. + -h : Print this help message. +Example usage: +$0 -d graphite.mydomain.com -n myhost +$0 -d graphite.mydomain.com -p 9198 -n myhost -f 600 +$0 -d graphite.mydomain.com -n myhost -f 600 -c -m /dev/sda -m /dev/sdc -t /dev/sdc=sat +EOF +} + +## +# Writes argument $1 to stdout if $QUIET is not set +# +# Arguments: +# $1 Message to write to stdout +## +function log() { + if [[ $QUIET -eq 0 ]]; then + echo "time=$(date --iso-8601=seconds) level=info msg=$1" + if [[ ! -z "$LOG_FILE" ]]; then + echo "time=$(date --iso-8601=seconds) level=info msg=$1" >> $LOG_FILE + fi + fi +} + +## +# Writes argument $1 to stdout if $VERBOSE is set and $QUIET is not set +# +# Arguments: +# $1 Message to write to stdout +## +function log_verbose() { + if [[ $VERBOSE -eq 1 ]] && [[ $QUIET -eq 0 ]]; then + echo "time=$(date --iso-8601=seconds) level=debug msg=$1" + if [[ ! -z "$LOG_FILE" ]]; then + echo "time=$(date --iso-8601=seconds) level=debug msg=$1" >> $LOG_FILE + fi + fi +} + +## +# Writes argument $1 to $LOG_FILE, appending to the file +# +# Arguments: +# $1 Message to write to the log file +## +function log_file() { + if [[ $VERBOSE -eq 1 ]] && [[ $QUIET -eq 0 ]] && [[ ! -z "$LOG_FILE" ]]; then + echo "time=$(date --iso-8601=seconds) level=debug msg=$1" >> $LOG_FILE + fi +} + +## +# Writes argument $1 to stderr. Ignores $QUIET. +# +# Arguments: +# $1 Message to write to stderr +## +function log_error() { + >&2 echo "time=$(date --iso-8601=seconds) level=error msg=$1" + if [[ ! -z "$LOG_FILE" ]]; then + echo "time=$(date --iso-8601=seconds) level=error msg=$1" >> $LOG_FILE + fi +} + +## +# Manually sets the device type for a specific device. Useful if +# smartctl auto-detection does not work correctly. +# +# Arguments: +# $1 Drive device type specification string in the form of =, e.g. /dev/sda=sat +## +function set_manual_device_type() { + local drive=$(cut -d'=' -f1 <<<"$1") + local device_type=$(cut -d'=' -f2 <<<"$1") + if [ -z "$drive" || -z "$device_type" ]; then + print_usage + fi + DRIVES[$drive]=$device_type +} + +## +# Registers a new drive in $DRIVES array and detects if it is an ATA or SCSI +# drive. +# +# Arguemnts: +# $1 Device identifier (e.g. /dev/ada0) +## +function register_drive() { + local drive="$1" + if [ -z "$drive" ]; then + log_error "Failed to register drive. Empty name received." + return 1 + fi + # Check if we need to use a manually provided device type for querying SMART initially + local device_type_argument="" + if [ ! -z "${DRIVES[$drive]}" ]; then + device_type_argument="-d ${DRIVES[$drive]}" + fi + + local smart_output=$(smartctl --json=c -a $device_type_argument $drive) + local common_tags=$(echo "$smart_output" | jq -r --arg HOSTNAME $HOSTNAME ' + (.model_family // "" | gsub(" "; "_")) as $model_family + | (.model_name // "" | gsub(" "; "_")) as $model_name + | (.serial_number | tostring) as $serial_number + | .firmware_version as $firmware_version + | (.user_capacity.bytes | tostring) as $user_capacity_bytes + | (.device.name | sub("/dev/"; "")) as $device_name + | .device.type as $device_type + | if $model_name != "" then "model_name=\($model_name);" else "" end + + if $model_family != "" then "model_family=\($model_family);" else "" end + + "serial_number=\($serial_number);" + + "firmware_version=\($firmware_version);" + + "user_capacity_bytes=\($user_capacity_bytes);" + + "device_name=\($device_name);" + + "device_type=\($device_type);" + + "instance=\($HOSTNAME)"') + DRIVE_COMMON_TAGS[$drive]="$common_tags" + + # detect device type if not provided by command line argument + if [ -z "${DRIVES[$drive]}" ]; then + local device_type=$(echo "$smart_output" | jq -r '.device.type') + DRIVES[$drive]=$device_type + fi +} + +## +# Detects all connected drives using plain iostat method and whether they are +# ATA or SCSI drives. Drives listed in $IGNORE_DRIVES will be excluded. +# +# Note: This function populates the $DRIVES array directly. +## +function detect_drives_smart() { + local DRIVE_DEVS=$(smartctl --json=c --scan-open | jq -r '.devices[].name') + + # Detect protocol type (ATA or SCSI) for each drive and populate $DRIVES array + for drive in ${DRIVE_DEVS}; do + register_drive "$drive" + done +} + +## +# Retrieves the list of identifiers (e.g. "ada0") for all monitored drives. +# Drives listed in $IGNORE_DRIVES will be excluded. +# +# Note: Must be run after detect_drives(). +## +function get_drives() { + echo "${!DRIVES[@]}" +} + + +## +# Gets all SMART attributes for the provided drive, named already as metrics. +# +# Arguments: +# $1 The drive device ID to get SMART attributes for, e.g. /dev/sda +# +# Returns +# A list of delimiter-separated (refer to $METRIC_NAME_VALUE_DELIMITER) SMART metrics with name and complete list of Graphite tags, e.g. +# smart_attribute;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1XXXXZJZ;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=samstorage.local.salvoxia.de;value_type=thresh;attribute_id=198;attribute_name=Offline_Uncorrectable>>0 +# OR smart_power_status;model_name=HGST_HUH721010ALE600;model_family=HGST_Ultrastar_He10;serial_number=1XXXXZJZ;firmware_version=LHGNT384;user_capacity_bytes=10000831348736;device_name=sda;device_type=sat;instance=samstorage.local.salvoxia.de>>0 if the device is in standy and attributes could not be retrieved +# OR "error" on any other error returned by smartctl +## +function get_smart_metrics() { + local drive="$1" + declare -A attributes + # Determine device type + local device_type=${DRIVES[$drive]} + # Get common drive tags + local common_tags=${DRIVE_COMMON_TAGS[$drive]} + # Read SMART attributes + smartctl --json=c -a -n standby -d $device_type $drive > $SMART_TEMP_FILE_NAME + # If 0 < exit_status <= 7, an error performing smartctl occurred. However, if messages contains a message that contains the keyword + # STANDBY or SLEEP, the device is in sleep mode and was not queried. + # The following filter accounts for the possibility that there are no messages at all + local exit_code=$(jq -r '.smartctl.exit_status as $exit_status + | try .smartctl.messages[].string catch "" + | (contains("STANDBY") or contains("SLEEP")) as $sleep + | if ($exit_status > 0 and $exit_status <= 7 and $sleep) then "standby" elif ($exit_status > 0 and $exit_status <= 7) then "error" else . end ' $SMART_TEMP_FILE_NAME) + + # Determine power status (drive active or in standby/sleep) + local smart_power_status=1 + if [ "$exit_code" == "standby" ]; then + smart_power_status=0 + fi + local smart_power_status_metric="$SMART_POWER_STATUS_METRIC_NAME;$common_tags>>$smart_power_status" + + # Exit status between 1 and 7 indicate either Standby or an hard error + if [ ! -z "$exit_code" ]; then + if [ "$exit_code" == "error" ]; then + echo "$exit_code" + else + # only return smart_power_statu_metric + echo "$smart_power_status_metric" + fi + # All other exit codes yield SMART attributes + else + local smart_attributes="" + + # Get SMART attributes depending on drive type + case $device_type in + "nvme") + local nvme_attributes=$(jq -r --arg common_tags "$common_tags" --arg delim $METRIC_NAME_VALUE_DELIMITER ' + .nvme_smart_health_information_log + | keys[] as $key + | "smart_nvme_attribute;\($common_tags);value_type=raw;attribute_name=\($key)\($delim)\(.[$key]|numbers)"' $SMART_TEMP_FILE_NAME) + local temperature_sensors=$(jq -r --arg common_tags "$common_tags" --arg delim $METRIC_NAME_VALUE_DELIMITER ' + .nvme_smart_health_information_log.temperature_sensors + | keys[] as $key + | "smart_nvme_attribute;\($common_tags);value_type=raw;attribute_name=temperature_sensor_\($key)\($delim)\(.[$key]|numbers)"' $SMART_TEMP_FILE_NAME) + + # Special metrics: Temperature, Power Cycle Count, Power on Time, Smart Status + local additional_metrics=$(jq -r --arg common_tags "$common_tags" --arg delim $METRIC_NAME_VALUE_DELIMITER ' + "smart_device_temperature;\($common_tags)\($delim)\(.temperature.current)", + "smart_power_cycle_count;\($common_tags)\($delim)\(.power_cycle_count)", + "smart_power_on_time_hours;\($common_tags)\($delim)\(.power_on_time.hours)", + "smart_status_passed;\($common_tags)\($delim)\(if .smart_status.passed then "1" else "0" end)"' $SMART_TEMP_FILE_NAME) + smart_attributes="${nvme_attributes} ${temperature_sensors} ${additional_metrics}" + ;; + "sat") + smart_attributes=$(jq -r --arg common_tags "$common_tags" --arg delim $METRIC_NAME_VALUE_DELIMITER ' + .ata_smart_attributes.table[] + | "smart_attribute;\($common_tags);value_type=value;attribute_id=\(.id);attribute_name=\(.name)\($delim)\(.value)", + "smart_attribute;\($common_tags);value_type=raw;attribute_id=\(.id);attribute_name=\(.name)\($delim)\(.raw.value)", + "smart_attribute;\($common_tags);value_type=thresh;attribute_id=\(.id);attribute_name=\(.name)\($delim)\(.thresh)", + "smart_attribute;\($common_tags);value_type=worst;attribute_id=\(.id);attribute_name=\(.name)\($delim)\(.worst)"' $SMART_TEMP_FILE_NAME) + # Special metric: Temperature + local additional_metrics=$(jq -r --arg common_tags "$common_tags" --arg delim $METRIC_NAME_VALUE_DELIMITER ' + "smart_device_temperature;\($common_tags)\($delim)\(.temperature.current)", + "smart_power_cycle_count;\($common_tags)\($delim)\(.power_cycle_count)", + "smart_power_on_time_hours;\($common_tags)\($delim)\(.power_on_time.hours)", + "smart_status_passed;\($common_tags)\($delim)\(if .smart_status.passed then "1" else "0" end)"' $SMART_TEMP_FILE_NAME) + smart_attributes="${smart_attributes} ${additional_metrics}" + ;; + esac + for smart_attribute in "${smart_attributes}"; do + echo $smart_attribute + done + echo $smart_power_status_metric + fi + rm $SMART_TEMP_FILE_NAME +} + +## +# Sends the metrics for all drives currently stored in global array +# METRICS to the Graphite server at DESTINATION on port PORT +## +function send_metrics { + # get current time in Unix timestamp format, save in $time + time=$(/bin/date +%s) + local verbose="" + if [ $VERBOSE -eq 1 ]; then + verbose="-v" + fi + + # only send if there are actually any metrics available + if [ ${#METRICS[@]} -gt 0 ]; then + for drive in ${!METRICS[@]}; do + local metrics_for_drive=${METRICS[$drive]} + # Check if we actually have metrics for that drive (might be in standby) + if [ ! -z "$metrics_for_drive" ]; then + for metric in $metrics_for_drive; do + local formatted_metric=$(echo "$metric" | sed -E "s/($METRIC_NAME_VALUE_DELIMITER)/ /") + echo "${formatted_metric} ${time}" + done + fi + done | nc "${DESTINATION}" "${PORT}" -w2 $verbose + fi +} + +## +# Main program loop +## +function main() { + log_verbose "Running SMART Graphite Exporter $VERSION" + + # Verify mandatory arguments + if [ -z $DESTINATION ] || [ -z $HOSTNAME ]; then + print_usage + exit 1 + fi + if [ $VERBOSE -eq 1 ] && [ $QUIET -eq 1 ]; then + echo "Either set -v OR -o, not both!" + print_usage + exit 1 + fi + + # Replace dots '.' in hostname with underscores + HOSTNAME_METRIC=${HOSTNAME//./_} + HOSTNAME_METRIC=$HOSTNAME + log_verbose "Destination Server: $DESTINATION" + log_verbose "Port: $PORT" + log_verbose "Hostname: $HOSTNAME" + log_verbose "Hostname in metrics: $HOSTNAME_METRIC" + log_verbose "Frequency: $FREQUENCY" + log_verbose "Verbose: $VERBOSE" + log_verbose "Disable drive detection: $DISABLE_DRIVE_DETECTION" + log_verbose "Manually specified drives: $(get_drives)" + + local smart_power_status_regex="$SMART_POWER_STATUS_METRIC_NAME(;\S+=\S+)+>>(0|1)" + + # Identify drives if no drives were provided as arguments + if [ $DISABLE_DRIVE_DETECTION -eq 0 ]; then + detect_drives_smart + fi + + for drive in ${!DRIVES[@]}; do + log_verbose "Using drive ${drive} as ${DRIVES[$drive]} device" + done + + log "Starting to send S.M.A.R.T. metrics with a frequency ${FREQUENCY} seconds: $(get_drives)" + + # Drive SMART monitoring loop + while true; do + for drive in "${!DRIVES[@]}"; do + local SMART_METRICS=$(get_smart_metrics $drive) + local power_status_metric=$(echo ${SMART_METRICS} | grep -Eo "${smart_power_status_regex}") + # If the power status metrics ends with 0, the device is in standby + if [[ "${power_status_metric}" == *0 ]]; then + if [ $OMIT_DRIVES_IN_STANDBY -eq 0 ]; then + log_verbose "Drive ${drive} is in standby, sending last known metrics" + # Update power status in existing metrics by replacing it via regex + METRICS[$drive]=$(sed --regexp-extended "s/${smart_power_status_regex}/${SMART_METRICS}/" <<< "${METRICS[$drive]}") + else + log_verbose "Drive ${drive} is in standby, will not send any metrics this cycle" + # Sets metrics to only inlcude the power status, as returned by get_smart_metrics + METRICS[$drive]="${SMART_METRICS}" + fi + fi + + if [ "${SMART_METRICS}" == "error" ]; then + log "Error querying SMART attributes for drive ${drive}!" + fi + + # Store metrics (empty if the drive is in standby) + if [ "${SMART_METRICS}" != "error" ] && [ "${SMART_METRICS}" != "standby" ]; then + log_verbose "Metrics for drive ${drive}: ${SMART_METRICS}" + METRICS[$drive]=$SMART_METRICS + fi + + done + # Send metrics to Graphite server + send_metrics + # Wait for next cycle + sleep $FREQUENCY + done +} + +# Parse arguments +while getopts "hd:p:n:vqf:cm:t:l:s:" opt; do + case ${opt} in + d ) DESTINATION=${OPTARG} + ;; + f ) FREQUENCY=${OPTARG} + ;; + l ) LOG_FILE=${OPTARG} + ;; + m ) register_drive ${OPTARG} + DISABLE_DRIVE_DETECTION=1 + ;; + n ) HOSTNAME=${OPTARG} + ;; + p ) PORT=${OPTARG} + ;; + c ) OMIT_DRIVES_IN_STANDBY=0 + ;; + s ) SMART_TEMP_FILE_NAME=${OPTARG} + ;; + t ) set_manual_device_type ${OPTARG} + ;; + q ) QUIET=1 + ;; + v ) VERBOSE=1 + ;; + h ) print_usage; exit + ;; + \? ) print_usage; exit + ;; + esac +done + +main # Start main program diff --git a/images/init_script_setup.png b/images/init_script_setup.png new file mode 100644 index 0000000..20d4d1a Binary files /dev/null and b/images/init_script_setup.png differ