Is there a SMART library for .NET or Java?

I asked a few questions , but I want this to make it more specific and “programmable,” so here it is:

Does any authority know if .NET , JAVA, or any other Framework, library, .jar file or anything exists : to access SMART Statistics?

Thank!

+3
source share
1 answer

SMART statistics can be obtained from .Net via the System.Management class and WMI "MSStorageDriver_ATAPISmartData".

Here is a brief example that I created for you. Run a new console project and add a reference to the System.Management assembly, then paste this into Program.cs:

using System;
using System.Collections.Generic;
using System.Text;
using System.Management;

namespace GetSMART
{
    class Program
    {
        static void Main(string[] args)
        {
            ManagementObjectSearcher searcher = 
            new ManagementObjectSearcher(
                "root\\WMI",
                "SELECT * FROM MSStorageDriver_ATAPISmartData"
            );

            foreach (ManagementObject item in searcher.Get())
            {
                foreach( PropertyData prop in item.Properties )
                {
                Console.WriteLine("{0} = {1}",
                    prop.Name, prop.Value);
                }
            }

            Console.ReadLine();
        }
    }
}
+5

Source: https://habr.com/ru/post/1697605/


All Articles