|Disk Drive Dangers - SMART and WMI|
|Written by Mike James|
|Wednesday, 08 August 2012|
Page 3 of 4
Now that we have the basics of WMI in .NET worked out it's time to get back to SMART. Some information presented by WMI is provided by SMART and this is fairly easy to get at.
For example, if you simply want to discover what SMART thinks of each drive you can make use of the WMI Win32_DiskDrive object and its Status property. This gives an overall disk status based on SMART and other considerations. The possible values are:
Pred Fail, i.e. Predicted Failure result, is the one that we are most interested in using as a way of avoiding trouble before it happens.
Start a new project, or use the previous project and place a button labelled “Get Drive Status” on the form along with a RichTextBox.
To read the Status property and present it enter the following into the button’s click event handler :
private void button1_Click(object sender,
The “\t”s are tab formatting characters and the “\n” is a newline.
If you want to go beyond this simple go/no-go test then there are a number of problems.
There are (at least) four WMI objects that provide access to SMART but lack of documentation makes them difficult to use. The only information available can be found in an archived paper on the Micorosft site which describes four objects:
The first provides information on the state of the drive similar to the state property already described. The second provides the SMART data that this decision was based on but the format used varies according to the make of the drive and no information is given how to decipher it. The third implements events based on the SMART status and the fourth provides methods that can be used to configure a SMART drive and initiate a test.
There is also another object:
but there seems to be even less documentation for this and it is only available in Vista and later. It seems to return the same information as
To get at the SMART data we need to use MSStorageDriver_FailurePredictData. This is stored in \root\wmi rather than the default \root\cimv2 and means we need to set the scope:
You can also specify a machine and user if you want to collect data on a remote machine. The WQL query is:
The FailDataSet contains a block of SMART data for each drive in the system that supports it. Each of the FailData objects in the collection has a VendorSpecific property which returns a byte array full of SMART data.
The big problem is in figuring out what it all means as it really is “vendor specific”. The data is organized into 12 byte blocks of attribute data. The first byte of the array gives the number of attribute blocks. Each attribute block has the format:
0 and 1 Unknown usually zero
The attribute codes are also not standardized but there are a core set that you can rely on:
Code Attribute 1 Raw Read Error Rate
Not all drives support all attributes and you can be certain that some will report attributes not in this list. A more complete list can be found on Wikipedia: SMART. Notice also that code 194 gives the temperature of the drive.
|Last Updated ( Wednesday, 08 August 2012 )|