KS-Soft. Network Management Solutions
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister    ProfileProfile    Log inLog in 

Active Script: Windows RAID monitoring

 
Post new topic   Reply to topic    KS-Soft Forum Index -> Library
View previous topic :: View next topic  
Author Message
SplanK



Joined: 21 Nov 2007
Posts: 38

PostPosted: Tue Oct 14, 2014 2:25 am    Post subject: Active Script: Windows RAID monitoring Reply with quote

We have a couple of machines here which use MS software RAID. I tweaked a script found here:
http://www.eventsentry.com/kb/211
to interrogate the status of the software raid.

It will report ok when status is Healtyh
It will report bad when status is not healthy
It will report unknown if there are no MS software raids found.

Code:

' Lists all logical drives on the local computer which are configured for
' software RAID.

Option Explicit

const statusAlive       = "Host is alive:"
const statusDead        = "No answer:"
const statusUnknown     = "Unknown:"
const statusNotResolved = "Unknown host:"
const statusOk          = "Ok:"
const statusBad         = "Bad:"
const statusBadContents = "Bad contents:"

FUNCTION PerformTest()

   Dim WshShell, oExec
   Dim RegexParse
   Dim oError, oReply, oCount, oSpacer
   oCount = 0
   oError = 0

   Set WshShell = CreateObject("WScript.Shell")
   Set RegexParse = New RegExp

   ' Execute diskpart
   Set oExec = WshShell.Exec("%comspec% /c echo list volume | diskpart.exe")

   RegexParse.Pattern = "\s\s(Volume\s\d)\s+([A-Z])\s+(.*)\s\s(NTFS|FAT)\s+(Mirror|RAID-5)\s+(\d+)\s+(..)\s\s([A-Za-z]*\s?[A-Za-z]*)(\s\s)*.*"

   While Not oExec.StdOut.AtEndOfStream
      Dim regexMatches
      Dim Volume, Drive, Description, Redundancy, RaidStatus
      Dim CurrentLine : CurrentLine = oExec.StdOut.ReadLine
      
      Set regexMatches = RegexParse.Execute(CurrentLine)
      If (regexMatches.Count > 0) Then
         Dim match
         Set match = regexMatches(0)
         
         If match.SubMatches.Count >= 8 Then
            Volume      = match.SubMatches(0)
            Drive       = match.SubMatches(1)
            Description = Trim(match.SubMatches(2))
            Redundancy  = match.SubMatches(4)
            RaidStatus  = Trim(match.SubMatches(7))
         End If

         If RaidStatus <> "Healthy" Then
            oError = 1
         End If
         
         'WScript.StdOut.WriteLine "Status of " & Redundancy & " " & Drive & ": (" & Description & ") is """ & RaidStatus & """"
   
         If oCount > 1 Then
            oSpacer = " / "
         Else
            oSpacer = ""
         End If
   
         oReply = oReply & oSpacer & Redundancy & " " & Drive & ": is " & RaidStatus
         oCount = oCount + 1
      End If
   Wend

   If oError = 1  Then
      PerformTest = statusBad+oReply
   Elseif oCount = 0 Then
      PerformTest = statusUnknown+"No Software RAID found " & oReply
   Else
      PerformTest = statusOk+oReply   
   End If
End Function

Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    KS-Soft Forum Index -> Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

KS-Soft Forum Index