-
Module for monitoring a Windows Soft RAID
I’ve been using this module to check the status of my Windows Soft RAID for a long time now and would like to share it with you. Suggestions for improvement always welcome!
——————————
‘ Agent Plugin to get current soft-raid status
‘ Execute as module_plugin cscript //B rck-raid.vbsOption Explicit
Dim WshShell, oExec
Dim Line, HealthyRE, MirrorRE, FailedRE, RebuildRE
Dim Failed, FailedStrFailed = -1
FailedStr = “INTERNAL ERROR”‘ Simple variable to display status of all volumes:
‘ 0 = Healthy
‘ 1 = Rebuilding
‘ 2 = Failed
‘ 3 = Unknown‘ Check version of WScript. Has to be >= 5.6 for WScript.Shell.Exec to work
If Wscript.Version < 5.6 Then Failed = 3 FailedStr = "WScript version < 5.6" WScript.Quit(3) End If Set WshShell = WScript.CreateObject("WScript.Shell") ' Execute the DISKPART program and grab the output Set oExec = WshShell.Exec("%comspec% /C echo list volume | %WINDIR%SYSTEM32DISKPART.EXE") ' Set up some regular expression objects Set HealthyRE = New RegExp HealthyRE.Pattern = "Healthy|Fehlerfre" Set MirrorRE = New RegExp MirrorRE.Pattern = "Mirror|RAID-5|Spiegelung" Set FailedRE = New RegExp FailedRE.Pattern = "Failed|(At Risk)|Risiko" ' At Risk indicates errors have been reported for a disk ' and it may need to be reactivated. Set RebuildRE = New RegExp RebuildRE.Pattern = "Rebuild|(Neu erste)" ' Check for no output If oExec.StdOut.AtEndOfStream Then Failed = 3 FailedStr = "NO OUTPUT" Else While Not oExec.StdOut.AtEndOfStream Line = oExec.StdOut.ReadLine ' Tests for Mirrored or RAID-5 volumes If MirrorRE.Test(Line) Then ' Tests for Healthy volumes If HealthyRE.Test(Line) Then If Failed = -1 Then Failed = 0 End If ' Tests for Failed RAID volumes If FailedRE.Test(Line) Then If Failed < 2 Then Failed = 2 ' Tests for Rebuilding volumes ElseIf RebuildRE.Test(Line) Then If Failed <=0 Then Failed = 1 End If End If WEnd End If ' If Failed is still -1, something bad has happened, or there is no RAID If Failed = -1 Then Failed = 3 FailedStr = "no RAID?" End If ' Print out the appropriate test result WScript.StdOut.WriteLine "”
WScript.StdOut.WriteLine ””
WScript.StdOut.WriteLine ””
WScript.StdOut.WriteLine ”” Select Case Failed
Case 0
WScript.StdOut.WriteLine ” ”
WScript.StdOut.WriteLine ””
WScript.StdOut.WriteLine ”” Case 1
WScript.StdOut.WriteLine ” ”
WScript.StdOut.WriteLine ””
WScript.StdOut.WriteLine ”” Case 2
WScript.StdOut.WriteLine ” ”
WScript.StdOut.WriteLine ””
WScript.StdOut.WriteLine ”” Case 3
WScript.StdOut.WriteLine ” ”
WScript.StdOut.WriteLine ””
WScript.StdOut.WriteLine ”” End Select
WScript.StdOut.WriteLine “”
WScript.Quit(0)
Sorry, there were no replies found.