Controller Virtual Disk Unit Monitor

Dell.WindowsServer.ControllerVirtualDiskUnitMonitor (UnitMonitor)

Knowledge Base article:

Summary

Dell Windows Server Controller Virtual Disk UnitMonitor

Element properties:

TargetDell.WindowsServer.ControllerVirtualDisk
Parent MonitorSystem.Health.AvailabilityState
CategoryCustom
EnabledTrue
Alert GenerateFalse
Alert Auto ResolveFalse
Monitor TypeMicrosoft.Windows.TimedScript.ThreeStateMonitorType
RemotableTrue
AccessibilityPublic
RunAsDefault

Source Code:

<UnitMonitor ID="Dell.WindowsServer.ControllerVirtualDiskUnitMonitor" Accessibility="Public" Enabled="true" Target="Dell.WindowsServer.ControllerVirtualDisk" ParentMonitorID="SystemHealth!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="Windows!Microsoft.Windows.TimedScript.ThreeStateMonitorType" ConfirmDelivery="false">
<Category>Custom</Category>
<OperationalStates>
<OperationalState ID="Dell.WindowsServer.ControllerVirtualDiskSuccess" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Dell.WindowsServer.ControllerVirtualDiskWarning" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="Dell.WindowsServer.ControllerVirtualDiskFailure" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>3600</IntervalSeconds>
<SyncTime/>
<ScriptName>ControllerVirtualDiskUnitMonitor.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Config/Computer$ $Target/Host/Host/Property[Type="ScalableWindowsServer!Dell.WindowsServer.StorageController"]/DeviceID$ $Target/Property[Type="Dell.WindowsServer.ControllerVirtualDisk"]/ID$</Arguments>
<ScriptBody><Script>
'**********************************************************************************
' Script Name - ControllerVirtualDiskUnitMonitor
' Author: Muralidhar, Vignesh
'
' Description:
' Determine Unit Monitor health for ControllerVirtualDisk
'
' (c) Copyright &#xA9; 2009&#x2013; 2017 Dell Inc, or its subsidiaries. All Rights Reserved
'**********************************************************************************
Option Explicit

SetLocale("en-us")

Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count &lt; 5 Then
Wscript.Quit -1
End If

Dim oAPI, prmDevice, controllerID

controllerID = oArgs(3)
prmDevice = oArgs(4)

Set oAPI = CreateObject("MOM.ScriptAPI")

Const WAIT_LOOP = 1000000
Const SCRIPT_NAME = "Dell Agents State Monitoring"
Const OM_REPORT_STORAGE_CONTR = "Storage"
Const DEF_OMSA_BIN_PATH = "C:\Program Files\Dell\OpenManage\oma\bin"
Const OMSA_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Dell Computer Corporation\Dell OMA\InstallPath"
Const OMSA64_REG_INTALL_PATH = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Dell Computer Corporation\Dell OMA\InstallPath"
Dim ObjectStatus

Dim s
Set s = New DellStorage
s.GetObjectHealth()

Dim cAPI, oBag
Set cAPI = CreateObject("MOM.ScriptAPI")
Set oBag = cAPI.CreatePropertyBag()
Call oBag.AddValue("Status", ObjectStatus)
Call cAPI.Return(oBag)

Set cAPI = Nothing
Set oBag = Nothing

Class DellStorage
Dim regError, logMessage, Message
Dim a, b

Dim rc, fileSpec, oShell
Dim strCommand, strRepFilePath, winTempPath

Function GetObjectHealth()
Dim OMSABinPath ' Store Path from Registry key
Dim drive ' Drive letter
Dim version
regError = 0

' Get OMSA Lib Path
rc = GetOMABinPath(OMSABinPath)
If rc &lt;&gt; 0 Then
WScript.Quit()
End If

' Get Install root path
rc = GetOMInstallRoot(drive, OMSABinPath) ' return the current absolute path or the root path for the OMSA Install
If rc &lt;&gt; 0 Then
WScript.Quit()
End If
If regError = 1 Then
Message = "Task Fail: OMSA not installed / OMSA Registry Value not found."
MOMDebugLog Message
WScript.Quit()
End If

' Check VBScript engine version
version = CheckVBScriptEngine()
If version = True OR version = False Then
RunCLI drive, OMSABinPath
Else
Message = "Error: VBScript corrupted/absent. Please Re-Install Windows Script 5.6 on the Agent"
MOMDebugLog Message
WScript.Quit()
End If
End Function

'*****************************************************************
'Function RunCLI
'Routine For CLI VB.Run (For Version &lt; 5.6)
'*****************************************************************
Function RunCLI(ByVal targetDrive, ByVal strOMSABinPath)
Dim guid1
GetTempFolderPath winTempPath, targetDrive
GetOMReportFileGUID guid1

RunStorageCLI targetDrive, strOMSABinPath
End Function

'*****************************************************************
'GetOMABinPath
'Routine to read the registry to query the OMA Install Path
'*****************************************************************
Function GetOMABinPath(o_sPath)
Dim oShell, tmp

Set oShell = CreateObject ("WScript.Shell")
o_sPath = ""
On Error Resume Next
o_sPath = oShell.RegRead(OMSA_REG_INTALL_PATH)
If o_sPath = "" Then
o_sPath = oShell.RegRead(OMSA64_REG_INTALL_PATH)
End If
If o_sPath = "" Then
tmp = DEF_OMSA_BIN_PATH &amp; "\omreport.exe"
If(bFileExists(tmp)) Then
o_sPath = DEF_OMSA_BIN_PATH
Message = "GetOMABinPath - OMSABinPath is empty, Using Default Existing Path" &amp; DEF_OMSA_BIN_PATH
MOMDebugLog Message
Else
regError = 1
End If
Else
o_sPath = o_sPath &amp; "\bin"
End If
If Err &lt;&gt; 0 Then
GetOMSABinPath = Err.Number
End If
End Function

'*****************************************************************
'GetOMInstallRoot
'Routine to determine the Drive letter where OMSA is installed
'*****************************************************************
Private Function GetOMInstallRoot(ByRef path, ByVal OMSAInstallPath)
On Error Resume Next
Err.Clear
' Return the root drive of the OMInstall Path
path = Left(OMSAInstallPath, 2)
End Function

'*****************************************************************
'bFileExists
'Routine to determine if the OMSA Report file is created
'*****************************************************************
Function bFileExists(filespec1)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
bFileExists = (fso.FileExists(filespec1))
Set fso = Nothing
End Function

'*****************************************************************
'DelFile
'Routine to delete the OMSA Report file
'*****************************************************************
Function DelFile(ByVal filespec2)
Dim fso
If bFileExists(filespec2) Then
Set fso = CreateObject("Scripting.FileSystemObject")
fso.DeleteFile filespec2, True
Set fso = Nothing
End If
If Err &lt;&gt; 0 Then
DelFile = Err.Number
End If
End Function

'**********************************************************
' CheckVBScriptEngine()
' Check VBScript engine version:
'**********************************************************
Function CheckVBScriptEngine()
On Error Resume Next
Dim bIsCompatV, var
Const VBSCRIPT_MIN_VERSION = 56
var = ((ScriptEngineMajorVersion * 10) + ScriptEngineMinorVersion)
If ((var) &lt; VBSCRIPT_MIN_VERSION) Then
bIsCompatV = False
Else
bIsCompatV = True
End If
If Err &lt;&gt; 0 Then
CheckVBScriptEngine = Err.Number
Err.Clear
Else
CheckVBScriptEngine = bIsCompatV
End If
End Function

'*****************************************************************
'Function RunStorageCLI - Called from RunCLI
'Routine For VB.Run (For Version &lt; 5.6)
'*****************************************************************
Function RunStorageCLI (ByVal Drive2, ByVal OMSABinPath)
Dim guid22
GetTempFolderPath winTempPath, Drive2
GetOMReportFileGUID guid22
a = 1
b = 0
strRepFilePath = winTempPath &amp; "\" &amp; OM_REPORT_STORAGE_CONTR &amp; guid22 &amp; ".xml"
strCommand = "cmd /C " &amp; chr(34) &amp; OMSABinPath &amp; "\" &amp; "omreport.exe" &amp; Chr(34) &amp; " storage vdisk controller=" &amp; controllerID &amp; " -fmt xml -outc " &amp; strRepFilePath
fileSpec = strRepFilePath
Set oShell = CreateObject ("WScript.Shell")
rc = oShell.run (strCommand,0,true)
If rc &lt;&gt; 0 Then
DelFile(strRepFilePath)
Else
' Infinite Loop Until file OM_REPORT_FILE_NAME is created
Do While bFileExists(fileSpec) &lt;&gt; -1
WScript.Sleep(0)
a = a + 1
b = a Mod WAIT_LOOP
If b = 0 Then
MOMDebugLog "Exit RunCmd. Reason: OMREPORT STORAGE not responding for " &amp; WAIT_LOOP &amp; " loops."
Exit Do
End If
Loop
' Parse XML File
ParseStorageXML fileSpec

' Clean up the CLI Output : Delete OM_REPORT_FILE_NAME for STORAGE
DelFile(strRepFilePath)
End If ' End of If Condition for rc&lt;&gt;0 for oshell.run(omreport storage controller)
Set strRepFilePath = Nothing
Set strCommand = Nothing
Set oShell = Nothing
Set fileSpec = Nothing
End Function

'*****************************************************************
' Function ParseStorageXML
' Rollup GlobalStorageHealth from OMSS StorageController XML Output
'*****************************************************************
Function ParseStorageXML(ByVal storagefilepath)
Dim object_health, object_arr
Dim obj, obj_val
Dim xmlDoc, i
If(bFileExists(storagefilepath)) Then
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
If (IsObject(xmlDoc) = True) Then
xmlDoc.async = "false"
xmlDoc.load(storagefilepath)
If (xmlDoc.parseError.errorCode &lt;&gt; 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
Message = "XML Parse Error Reason: " &amp; myErr.reason
MOMDebugLog Message
Message = "XML Parse Error Line: " &amp; myErr.line
MOMDebugLog Message
Message = "XML Parse Error Character: " &amp; myErr.linepos
MOMDebugLog Message
Message = "XML Parse Error Text: " &amp; myErr.srcText
MOMDebugLog Message
DelFile(storagefilepath)
Exit Function
End If

Set object_arr = xmlDoc.getElementsByTagName("TreeStatus")
Set obj = xmlDoc.getElementsByTagName("LogicalDriveNum")
object_health = 0

For i = 0 To (object_arr.length - 1)
object_health = object_arr.Item(i).nodeTypedValue

If (obj.length &gt; 0) Then
obj_val = obj.Item(i).nodeTypedValue

If (StrComp(prmDevice,obj_val,1)=0) Then
If object_health = 2 Then
ObjectStatus = "OK"
ElseIf object_health = 3 Then
ObjectStatus = "Warning"
ElseIf object_health = 4 Then
ObjectStatus = "Error"
End If
End If
Else
ObjectStatus = "OK"
End If
Next
Else
Message = "Error: DOM object not created using CreateObject - Microsoft.XMLDOM"
MOMDebugLog Message
End If
Else
Message = "Storage CLI XML Output File does not exist - " &amp; storagefilepath
MOMDebugLog Message
End If
End Function

'*****************************************************************
' Function MOMDebugLog
' Add logMessage Header - ScriptName and Time and Logging it.
'*****************************************************************
Function MOMDebugLog (ByVal strMessage)
logMessage = "(" &amp; SCRIPT_NAME &amp; ")" &amp; "-" &amp; "[" &amp; Now() &amp; "] --- "
logMessage = logMessage &amp; strMessage
End Function

'*****************************************************************
'GetTempFolderPath
'Routine to Get Win Temp Folder path
'*****************************************************************
Function GetTempFolderPath(ByRef WinTempFolder, ByVal drive_letter)
Dim fldrExistFlag, fso
fldrExistFlag = False
dim wshShell : Set wshShell = Createobject("WScript.Shell")
dim wshSysEnv : Set wshSysEnv = wshShell.Environment
dim strSysTempFolder : strSysTempFolder = wshSysEnv("TEMP")
dim wshPrcEnv : Set wshPrcEnv = wshShell.Environment("Process")
strSysTempFolder = Replace(strSysTempFolder, "%SystemRoot%", wshPrcEnv("SYSTEMROOT"), 1, -1, vbTextCompare)
WinTempFolder = strSysTempFolder

Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(WinTempFolder)) Then
fldrExistFlag = True
Else
fldrExistFlag = False
End If

If WinTempFolder = "" OR fldrExistFlag = False Then
WinTempFolder = drive_letter
End If

Set wshShell = Nothing
Set wshSysEnv = Nothing
Set strSysTempFolder = Nothing
Set wshPrcEnv = Nothing

If Err &lt;&gt; 0 Then
GetTempFolderPath = Err.Number
End If
End Function

'*****************************************************************
'GetOMReportFileGUID
'Routine to generate unique GUIDs for OMREPORT FILE
'*****************************************************************
Function GetOMReportFileGUID(ByRef o_guid)
Dim TypeLib, NewGUID
Set TypeLib = CreateObject("Scriptlet.TypeLib")
NewGUID = TypeLib.Guid
o_guid = (left(NewGUID, len(NewGUID)-2))
Set TypeLib = Nothing
End Function
End Class
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Error</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<WarningExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Warning</Value>
</ValueExpression>
</SimpleExpression>
</WarningExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery>Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">OK</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>