Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I want to write a script (using python or windows batch) to check if in the raid system on a winows 2003 server all disks are online, alive and synced.

This is the builtin windows 2003 software raid that I am using.

How can I get this information from a script that I run periodically?

Edit: I tried the code form the accepted answer. On my system all the disk information is given, except "Status", which always returns "None".

I found another soulution here:

http://www.anchor.com.au/hosting/dedicated/monitoring_windows_software_raid

Calling "echo list volume | diskpart" from a script and checking the returned output with regular expressions. There is one line for each drive. Possible string values for status depend on the language of your OS. Not very nice but works.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

You're looking for the Win32_LogicalDisk WMI class (Specifically the status property)

You could use either PowerShell or VBScript to access this class.

Note I Don't have a Software Raid setup to test these against and they are just samples not fully fleshed out code

A quick PowerShell Script would look something like this:

$CheckDrive = gwmi -query "Select * from Win32_LogicalDisk where DeviceID='C:'"
$CheckDrive.properties.status

Or if you wanted to loop through a bunch of drives you could do something like:

$CheckDrive = gwmi Win32_LogicalDisk
foreach ($i in $CheckDrive){$i.properties.Status}

From the linked site here are the options of the status output:

Status

   Data type: string
   Access type: Read-only

Current status of the object. Various operational and nonoperational statuses can be defined. Operational statuses include: "OK", "Degraded", and "Pred Fail" (an element, such as a SMART-enabled hard disk drive, may be functioning properly but predicting a failure in the near future). Nonoperational statuses include: "Error", "Starting", "Stopping", and "Service". The latter, "Service", could apply during mirror-resilvering of a disk, reload of a user permissions list, or other administrative work. Not all such work is online, yet the managed element is neither "OK" nor in one of the other states. This property is inherited from CIM_ManagedSystemElement.

   The values are:

   "OK"
   "Error"
   "Degraded"
   "Unknown"
   "Pred Fail"
   "Starting"
   "Stopping"
   "Service"
   "Stressed"
   "NonRecover"
   "No Contact"
   "Lost Comm"
share|improve this answer
    
thank you for the fast reply, looks great, will try it out soon –  user12096 Jan 14 '10 at 8:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.