'Constants to define resource status
Const RES_STATUS_HEALTHY = "Status_Healthy"
Const RES_STATUS_UNHEALTHY = "Status_Unhealthy"
Const RES_STATUS_WARNING = "Status_Warning"
'Variable to store handle for MOM script API
Dim oMOMScriptAPI
'Variables to store input arguments for script
Dim ArgResName, ArgResState, ArgSGName, ArgTargetComputer
'Call main function
Main()
'*********************************** Main Function **************************************
Function Main()
'Create and save handle for MOM script API
Set oMOMScriptAPI = CreateObject("MOM.ScriptAPI")
'############### Read and parse script arguments ##############
Dim oScriptArgs
Set oScriptArgs = WScript.Arguments
'******* Check for the required script arguments. If the script is called without the required arguments,
' create an information event and then quit.
if oScriptArgs.Count < 4 Then
Call oMOMScriptAPI.LogScriptEvent("VCSScriptResMonitoring.vbs",901,0,"VCSScriptDiscovery.vbs script was no executed because it was called with less than three arguments.")
Wscript.Quit -1
End If
'******* Read script arguments
ArgResName = oScriptArgs(0)
ArgResState = oScriptArgs(1)
ArgSGName = oScriptArgs(2)
ArgTargetComputer = oScriptArgs(3) ' The FQDN of the computer targeted by the script.
'############ Call function to create property bag for Resource ############
CreateResStatePropertyBag()
End Function
'********************************* End Main Function ************************************
'**************************** CreateResStatePropertyBag Function *************************
Function CreateResStatePropertyBag()
'############## Create property bag for Resource state ##############
'******* Parse Resource State
Dim strResStatus
Select Case (ArgResState)
Case "OFFLINE": strResStatus = RES_STATUS_UNHEALTHY
Case "FAULTED": strResStatus = RES_STATUS_UNHEALTHY
Case "ONLINE": strResStatus = RES_STATUS_HEALTHY
Case "OFFLINE_ON_NODE": strResStatus = RES_STATUS_WARNING
Case Else: strResStatus = RES_STATUS_HEALTHY
End Select
'******* Create property bag for status
Dim oPropertyBag
Set oPropertyBag = oMOMScriptAPI.CreatePropertyBag()
Call oPropertyBag.AddValue("ResStatus",strResStatus)
'Call oMOMScriptAPI.LogScriptEvent("VCSScriptResMonitoring.vbs",903,0, "Status for " + ArgResName + " is: " + strResStatus )
'############# Create property bag for Alert description ##############
Dim strAlertMsg
strAlertMsg = "No Alert"
'******* Check Resource status and create alert description accordingly
If strResStatus = "Status_Unhealthy" Then
strAlertMsg = "The Resource " + ArgResName + " in Service Group " + ArgSGName + " on " + ArgTargetComputer + " has failed or it is unavailable."
ElseIf strResStatus = "Status_Warning" Then
strAlertMsg = "The Resource " + ArgResName + " in Service Group " + ArgSGName + " on " + ArgTargetComputer + " is in a pending state or it is partially online."
End If
'******* Create property bag for alert description
Call oPropertyBag.AddValue("ResAlertDescription", strAlertMsg)
'Call oMOMScriptAPI.LogScriptEvent("VCSScriptResMonitoring.vbs",904,0, "Alert Description is: " + strAlertMsg )
'############### Return property bag to MOM server ##############
'Call oMOMScriptAPI.LogScriptEvent("VCSScriptResMonitoring.vbs",905,0, "Returning property bag for Resource: " + ArgResName)
Call oMOMScriptAPI.Return(oPropertyBag)