Dell Windows Server Connector Physical Disk UnitMonitor
Target | Dell.WindowsServer.ConnectorPhysicalDisk |
Parent Monitor | System.Health.AvailabilityState |
Category | Custom |
Enabled | True |
Alert Generate | False |
Alert Auto Resolve | False |
Monitor Type | Microsoft.Windows.TimedScript.ThreeStateMonitorType |
Remotable | True |
Accessibility | Public |
RunAs | Default |
<UnitMonitor ID="Dell.WindowsServer.ConnectorPhysicalDiskUnitMonitor" Accessibility="Public" Enabled="true" Target="Dell.WindowsServer.ConnectorPhysicalDisk" 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.ConnectorPhysicalDiskSuccess" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Dell.WindowsServer.ConnectorPhysicalDiskWarning" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="Dell.WindowsServer.ConnectorPhysicalDiskFailure" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>3600</IntervalSeconds>
<SyncTime/>
<ScriptName>ConnectorPhysicalDiskUnitMonitor.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Config/Computer$ $Target/Host/Host/Host/Property[Type="ScalableWindowsServer!Dell.WindowsServer.StorageController"]/DeviceID$ $Target/Property[Type="Dell.WindowsServer.ConnectorPhysicalDisk"]/SerialNumber$</Arguments>
<ScriptBody>
'**********************************************************************************
' Script Name - ConnectorPhysicalDiskUnitMonitor
' Author: Muralidhar, Vignesh
'
' Description:
' Determine Unit Monitor health for ConnectorPhysicalDisk
'
' (c) Copyright © 2009– 2017 Dell Inc, or its subsidiaries. All Rights Reserved
'**********************************************************************************
Option Explicit
SetLocale("en-us")
Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count < 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 <> 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 <> 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 < 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 & "\omreport.exe"
If(bFileExists(tmp)) Then
o_sPath = DEF_OMSA_BIN_PATH
Message = "GetOMABinPath - OMSABinPath is empty, Using Default Existing Path" & DEF_OMSA_BIN_PATH
MOMDebugLog Message
Else
regError = 1
End If
Else
o_sPath = o_sPath & "\bin"
End If
If Err <> 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 <> 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) < VBSCRIPT_MIN_VERSION) Then
bIsCompatV = False
Else
bIsCompatV = True
End If
If Err <> 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 < 5.6)
'*****************************************************************
Function RunStorageCLI (ByVal Drive2, ByVal OMSABinPath)
Dim guid22
GetTempFolderPath winTempPath, Drive2
GetOMReportFileGUID guid22
a = 1
b = 0
strRepFilePath = winTempPath & "\" & OM_REPORT_STORAGE_CONTR & guid22 & ".xml"
strCommand = "cmd /C " & chr(34) & OMSABinPath & "\" & "omreport.exe" & Chr(34) & " storage pdisk controller=" & controllerID & " -fmt xml -outc " & strRepFilePath
fileSpec = strRepFilePath
Set oShell = CreateObject ("WScript.Shell")
rc = oShell.run (strCommand,0,true)
If rc <> 0 Then
DelFile(strRepFilePath)
Else
' Infinite Loop Until file OM_REPORT_FILE_NAME is created
Do While bFileExists(fileSpec) <> -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 " & WAIT_LOOP & " 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<>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 <> 0) Then
Dim myErr
Set myErr = xmlDoc.parseError
Message = "XML Parse Error Reason: " & myErr.reason
MOMDebugLog Message
Message = "XML Parse Error Line: " & myErr.line
MOMDebugLog Message
Message = "XML Parse Error Character: " & myErr.linepos
MOMDebugLog Message
Message = "XML Parse Error Text: " & myErr.srcText
MOMDebugLog Message
DelFile(storagefilepath)
Exit Function
End If
Set object_arr = xmlDoc.getElementsByTagName("TreeStatus")
Set obj = xmlDoc.getElementsByTagName("DeviceSerialNumber")
object_health = 0
For i = 0 To (object_arr.length - 1)
If (obj.length > 0) Then
If not obj.Item(i) is Nothing Then
obj_val = obj.Item(i).nodeTypedValue
object_health = object_arr.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
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 - " & storagefilepath
MOMDebugLog Message
End If
End Function
'*****************************************************************
' Function MOMDebugLog
' Add logMessage Header - ScriptName and Time and Logging it.
'*****************************************************************
Function MOMDebugLog (ByVal strMessage)
logMessage = "(" & SCRIPT_NAME & ")" & "-" & "[" & Now() & "] --- "
logMessage = logMessage & 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 <> 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
</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>