' LSI cfggen RAID status check script: check_raid_lsi-fusion-mpt.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_raid_lsi-fusion-mpt.vbs" ' ' Doc: http://docs.sun.com/source/820-4933-15/cfggen2.html ' Bin: http://www-947.ibm.com/systems/support/supportsite.wss/docdisplay?lndocid=MIGR-5084107&brandind=5000020 ' Based on softraid: http://www.anchor.com.au/hosting/dedicated/monitoring_windows_software_raid 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%\LSICim\cfggen_scsi.exe 0 status") ' 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 = "Volume state" RE2.Pattern = "Degraded|Failed" RE3.Pattern = "Synchronize" RE4.Pattern = "Current operation" ' 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 Rebuild = 1 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 Rebuild = 0 Then If Failed < 2 Then Failed = 2 ElseIf Failed < 2 Then Failed = 1 End If 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)