Description for the new unit monitor.
Target | PowerToolsShm.EnclosureVoltageSensor |
Parent Monitor | System.Health.EntityState |
Category | AvailabilityHealth |
Enabled | True |
Alert Generate | False |
Alert Auto Resolve | False |
Monitor Type | Microsoft.Windows.TimedScript.ThreeStateMonitorType |
Remotable | True |
Accessibility | Internal |
RunAs | Default |
<UnitMonitor ID="PowerToolsShm.Shm.VoltageSensor.Monitor.vbs" Accessibility="Internal" Enabled="true" Target="PowerToolsShm.EnclosureVoltageSensor" ParentMonitorID="Health!System.Health.EntityState" Remotable="true" Priority="Normal" TypeID="Windows!Microsoft.Windows.TimedScript.ThreeStateMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<OperationalStates>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
<OperationalState ID="Warning" MonitorTypeStateID="Warning" HealthState="Warning"/>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<ScriptName>EnclosureElementMonitor.vbs</ScriptName>
<Arguments>voltagesensors $Target/Property[Type="PowerToolsShm.EnclosureVoltageSensor"]/EnclosureWWID$ $Target/Property[Type="PowerToolsShm.EnclosureVoltageSensor"]/ElementIndex$</Arguments>
<ScriptBody> Option Explicit
Const HKEY_LOCAL_MACHINE = &H80000002
Dim restReq, url, userName, password, oAPI, oBag
Dim elementType, uid, encId
elementType = WScript.Arguments(0)
encId = WScript.Arguments(1)
uid = WScript.Arguments(2)
Set restReq = CreateObject("MSXML2.ServerXMLHTTP")
restReq.setTimeouts 5000, 5000, 240000, 240000
' Instantiate MOM API
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
On Error Resume Next
'''''''''''''''''''''''''''''''''''''''''
Dim restUrl, value
dim sRegValue
sRegValue = ReadRegStr (HKEY_LOCAL_MACHINE, "SOFTWARE\Dell, Inc.\PowerTools\ServerHardwareManager\ServerManager", "RestAddress", 64)
if err.number <> 0 then
call oAPI.LogScriptEvent("DriveMonitor",8002,1,"Error (" & restReq.status & ") connecting to REST server (will attempt to use default 127.0.0.1:8012")
restUrl= "http://127.0.0.1:8012"
else
restUrl = "http://" & sRegValue
end if
url = restUrl & "/api/SEM/1.0/enc/" & encId & "/" + elementType + "/" + uid + "/status"
'call oAPI.LogScriptEvent("DriveMonitor",8003,1,url)
'''''''''''''''''''''''''''''''''''''''''
restReq.open "GET", url, false
restReq.send
If restReq.Status >= 400 And restReq.Status <= 599 Then
WScript.echo "Error communicating with REST server"
call oAPI.LogScriptEvent("SHM Enclosure Element Monitor",8001,1,"Error connecting to REST server: " & restReq.Status)
End If
Dim ResultArray,i
ResultArray = Split(restReq.responseText,"\n")
Dim errorPos
errorPos = InStr(restReq.responseText,"No target objects found for specified criteria.")
if (errorPos <= 0) then
Dim statusPos, startPos, endPos, statusString
WScript.echo restReq.responseText
WScript.echo """Status"":"
statusPos = InStr(restReq.responseText,"""Status"":")
WScript.echo statusPos
If (statusPos > 0) Then
' find next two quotes
startPos = InStr(statusPos+8,restReq.responseText,"""")
WScript.echo startPos
endPos = InStr(startPos+1,restReq.responseText,"""")
WScript.echo endPos
' between the two quotes is the status
statusString = Mid(restReq.responseText,startPos+1,endPos-startPos-1)
WScript.echo statusString
end if
If len(statusString) = 0 then
call oAPI.LogScriptEvent("EnclosureMonitor",8005,1,"Status=" & statusString & "____" & url)
End If
call oBag.AddValue("Status",statusString)
end if
call oAPI.Return(oBag)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function ReadRegStr (RootKey, Key, Value, RegType)
Dim oCtx, oLocator, oReg, oInParams, oOutParams
Set oCtx = CreateObject("WbemScripting.SWbemNamedValueSet")
oCtx.Add "__ProviderArchitecture", RegType
Set oLocator = CreateObject("Wbemscripting.SWbemLocator")
Set oReg = oLocator.ConnectServer("", "root\default", "", "", , , , oCtx).Get("StdRegProv")
Set oInParams = oReg.Methods_("GetStringValue").InParameters
oInParams.hDefKey = RootKey
oInParams.sSubKeyName = Key
oInParams.sValueName = Value
Set oOutParams = oReg.ExecMethod_("GetStringValue", oInParams, , oCtx)
ReadRegStr = oOutParams.sValue
End Function
</ScriptBody>
<SecureInput/>
<TimeoutSeconds>60</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">CRITICAL</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<WarningExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">NON CRITICAL</Value>
</ValueExpression>
</SimpleExpression>
</WarningExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">OK</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>