tags:

views:

154

answers:

4

Hello SO people,

I was looking around for a tool to monitor the status of my software raid under Windows 2003 Server, but couldn't find anything suitable (i.e. not grossly oversized or needlessly complicated). So I decided to just do it myself, it's nothing spectacularly difficult.

So how can I retrieve the status of the volumes programmatically? It's been a while since I fiddled with the Windows API and I couldn't find anything right off the bat using Google. I know I can use diskpart /s and parse its output, but that gets messy fairly quickly (although it does have some advantages).

Any pointers into the right direction are highly appreciated :)

A: 

Did you check WMI?

You can take a look here for a demo.

kek444
WMI doesn't return the raid status (see http://www.anchor.com.au/hosting/dedicated/monitoring_windows_software_raid)
n3rd
Thanks, didn't know that.
kek444
A: 

You could try monitoring the Event log for RAID events.

Shiraz Bhaiji
Yes, that's another option (see one of my links above). I'd rather query the status directly, though.
n3rd
A: 

I don't know if RAID stuff will complicate matters, but I've used System.IO.DriveInfo.GetDrives() before and that's worked fine for my needs.

Mark Simpson
A: 

The Win32 API is the (apparently only) way to go here, Virtual Disk Service is the magic word.

Here is a good example in C++ that will get you started. The number of different COM interfaces was pretty confusing for me at first, but the How Virtual Disk Service Works article was of great help getting the big picture.

It's actually pretty easy. Despite never having done any serious C++ coding and never having even touched COM before, I was still able to get the basic functionality to work in a few hours.

n3rd