' HP Fake RAID status check script: check_hp_fakeraid.vbs ' Vincent Tamet ' ' v0.2 2010-07-28 ' v0.1 2010-07-26 ' ' !!! The script is for ONE volume only, if not you must finish it !!! ' Still wondering if rebuilding is warning level !? ' 'command[check_raid]=c:\Windows\system32\cscript.exe //NoLogo C:\nrpe\plugins2\check_hp_fakeraid.vbs" ' ' ' ' Based on softraid http://www.anchor.com.au/hosting/dedicated/monitoring_windows_software_raid ' Bin: http://www.hp.com : HP Embedded G5 SATA RAID Controller Command Line Interface for Windows 2003/2008 (x86) ' Doc: I do the folowing test : hrconf.exe getconfig 1 ' ' OK: ' Status of logical drive : Optimal ' State : Online ' State : Online ' Degraded: ' Status of logical drive : Degraded ' State : Online ' Rebuiding: ' Status of logical drive : Degraded ' State : Rebuilding ' State : Online Option Explicit Dim WshShell, oExec Dim Line, RE0, RE1, RE2, RE3, RE4 Dim Failed, Rebuild Failed = -1 ' 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 Wscript.StdOut.WriteLine("UNKNOWN: WScript version < 5.6") WScript.Quit(Failed) End If Set WshShell = WScript.CreateObject("WScript.Shell") ' Execute the util program and grab the output Set oExec = WshShell.Exec("%ProgramFiles%\HP\HP Storage Manager\hrconf.exe getconfig 1") ' Set up some regular expression objects Set RE0 = New RegExp Set RE1 = New RegExp Set RE2 = New RegExp Set RE3 = New RegExp Set RE4 = New RegExp RE0.Pattern = "Optimal" RE1.Pattern = "Status of logical drive" RE2.Pattern = "Failed|Degraded" RE3.Pattern = "Rebuilding" RE4.Pattern = "State" ' Check for no output If oExec.StdOut.AtEndOfStream Then Failed = 3 Rebuild = 0 Else While Not oExec.StdOut.AtEndOfStream Line = oExec.StdOut.ReadLine 'Debug '''WScript.StdOut.WriteLine(Line) ' Tests for Rebuild volumes If RE4.Test(Line) Then If RE3.Test(Line) Then If Failed = 2 Then Failed = 1 End If End If ' Tests for Raid volumes If RE1.Test(Line) Then ' Tests for Optimal volumes If RE0.Test(Line) Then If Failed = -1 Then Failed = 0 End If ' Tests for Failed RAID volumes If RE2.Test(Line) Then If Failed < 2 Then Failed = 2 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 ' Print out the appropriate test result Select Case Failed Case 0 WScript.StdOut.WriteLine("RAID OK: All volumes Optimal") Case 1 WScript.StdOut.WriteLine("RAID WARNING: Volume(s) Rebuilding") Case 2 WScript.StdOut.WriteLine("RAID CRITICAL: Volume(s) have Failed") Case 3 WScript.StdOut.WriteLine("RAID UNKNOWN: " + oExec.StdErr.ReadLine) End Select WScript.Quit(Failed)