SMART data via CLI

Soldato
Joined
1 Aug 2003
Posts
3,797
Location
Cheshire
Over the years I've written a dashboarding application for my NAS that lets me see critical information in one place. Data is in a mySQL db, with the front end provided by Grafana. Works really nicely. One thing that it's missing is SMART data, charted over time, so I can see any worrying trends.

Does anyone know of a way to capture SMART data via the command line in windows? Do any free apps offer a CLI interface? Most seem to be GUI only. I know about the WMIC diskdrive stats and it's not enough, I want raw SMART data. My monitoring app is written in Java, so another option would be some off the shelf Jar\API (unlikely), or alternatively an exe that I can make a dodgy JNI call to.

I'm running 10 drives with over 50TB so quite keen to automate this.
 
Last edited:
Answering my own question;

Smartmon tools is the answer.

C:\Program Files\smartmontools\bin>smartctl.exe -A /dev/sda
smartctl 6.6 2017-11-05 r4594 [x86_64-w64-mingw32-w10-1709] (sf-6.6-1)
Copyright (C) 2002-17, Bruce Allen, Christian Franke, www.smartmontools.org

=== START OF INFORMATION SECTION ===
Model Family: Samsung based SSDs
Device Model: Samsung SSD 850 PRO 512GB
Serial Number: xxxxxxxxxxxxxxxxxx
Firmware Version: EXM01B6Q
Device is: In smartctl database [for details use: -P show]
ATA Version is: [No Information Found]
Local Time is: Wed Feb 21 19:30:00 2018 GMTST
SMART support is: Available - device has SMART capability.
Enabled status cached by OS, trying SMART RETURN STATUS cmd.
SMART support is: Enabled

Warning: Limited functionality due to missing admin rights
Read SMART Thresholds failed: Function not implemented

=== START OF READ SMART DATA SECTION ===
SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
5 Reallocated_Sector_Ct 0x0033 100 100 --- Pre-fail Always - 0
9 Power_On_Hours 0x0032 097 097 --- Old_age Always - 12296
12 Power_Cycle_Count 0x0032 097 097 --- Old_age Always - 2539
177 Wear_Leveling_Count 0x0013 098 098 --- Pre-fail Always - 67
179 Used_Rsvd_Blk_Cnt_Tot 0x0013 100 100 --- Pre-fail Always - 0
181 Program_Fail_Cnt_Total 0x0032 100 100 --- Old_age Always - 0
182 Erase_Fail_Count_Total 0x0032 100 100 --- Old_age Always - 0
183 Runtime_Bad_Block 0x0013 100 100 --- Pre-fail Always - 0
187 Uncorrectable_Error_Cnt 0x0032 100 100 --- Old_age Always - 0
190 Airflow_Temperature_Cel 0x0032 072 054 --- Old_age Always - 28
195 ECC_Error_Rate 0x001a 200 200 --- Old_age Always - 0
199 CRC_Error_Count 0x003e 100 100 --- Old_age Always - 0
235 POR_Recovery_Count 0x0012 099 099 --- Old_age Always - 49
241 Total_LBAs_Written 0x0032 099 099 --- Old_age Always - 63444721478
 
So here's the rough version of what I knocked up;

Turns out that smartctl can only read the SMART data if WD drives are active (spinning). As I want to passively monitor, and not cause spin-ups just to read data, it polls the drives frequently (every 1 hr) and stores what it can. So during last night for example, it couldn't get any data as the drives were sleeping. Idea is, that over time it'll grab what it can and from there I'll have trends available.

The top panel shows current status, obviously the cells are coloured depending on the value (temps, power on time, errors etc). It just shows the most recent data for each unique physical drive. I'll probably trigger alerts (emails, whatever) from this in the future.

The middle panel shows all of the historical data for each metric, for each drive. I can just filter the series as needed to home in on particular stats.

I'm going to add warranty tracking to this too, with the expiry periods mapped to each serial number. Have that in a spreadsheet currently.

Getting there..

28378893_10155365157403034_4993218750447013887_n.jpg
 
Back
Top Bottom