in reply to SMART info from drives in win32 using WMI

I don't know much about WMI resources, but I do know that when dealing with data structures - Data::Dumper::Simple is my very best friend :)

Adding the following to your code...

use Data::Dumper::Simple; # your code here... print Dumper($res);

...yields the following result on my Win32 machine...

$res = bless( { 'Count' => undef, 'Security_' => bless( { 'ImpersonationLevel' => 3, 'AuthenticationLevel' => 6, 'Privileges' => bless( { 'Coun +t' => 1 }, 'Win +32::OLE' ) }, 'Win32::OLE' ) }, 'Win32::OLE' );

So I guess the resulting data structure is a little more complex than just a simple hash. No smartdrive info there of course (because I'm not running any), but I suspect that if you try the same thing on your machine you might find the clue that you need.

Hope this helps,
Darren :)

Replies are listed 'Best First'.
Re^2: SMART info from drives in win32 using WMI
by Nemurenai (Acolyte) on May 17, 2006 at 13:52 UTC
    Thanks for the reply, but Dumper doesn't provide me with anything useful; if I replace the last part of the code with
    my $DriveCollection = $WMIServices->InstancesOf("Win32_DiskDrive" ); foreach my $Drive ( in( $DriveCollection ) ) { print Dumper $Drive; print $Drive->{'Status'}; }
    I get a huge dump of a data structure and then the text 'OK' -the property 'Status' is documented in http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_diskdrive.asp but not hinted at anywhere in the Dumper output. I can't find a corresponding page for querying SMART info, hence my question.
      Well, again let me point out that I know next to nothing about WMI, so I could be very well just blowing air out my rear-end here. However, looking at that "link" you gave I see the following:
      For IDE, this polling consists of sending the READ_SMART_STATUS comman +d. If this status indicates an error, a WMI event will be launched th +at includes the SMART attribute data.

      It doesn't actually specify what is returned in the absence of an error. Your reply infers that print $Drive->{'Status'}; produces 'OK' ...could it be that this is the entirety of the status?

      Cheers,
      Darren :)

        Oops, I mistyped
        MSStorageDriver_FailurePredictData
        (wrote 'MMStorage...'). Anyway, the
        $Drive->{'Status'}
        post was an example of pulling data from one of the data structures. Note, however, that the query is on
        Win32_DiskData
        which doesn't contain SMART info. I've looked at a header file (wmidata.h) in the MS DDK and gleaned a couple of the properties that the data stucture should have (SelfTestStatus, TotalTime + others). However, I can't even get that to work. Perhaps this is too win32 specific, but I can't figure out where else to ask about it. Besides, I'd hoped somebody had a clever answer about figuring out which attributes could be found. Thanks for the help though. Dumper will probably come in handy later :-p