Create a MOM Event Data Object in a MOM .vbs Script
Create a MOM Performance Data Object in a MOM .vbs Script
Create a MOM Alert Data Object in a MOM .vbs Script
Execute a cmd shell command and parse its results from within an Event Context MOM vbs
Create a MOM EventData Object in a MOM .vbs Script
Descriptive:
<!--CODE START--!>
pre
<!--CODE END--!>
Paste-able:
<!--CODE START--!>
pre
<!--CODE END--!>
Create a MOM Performance Data Object in a MOM .vbs Script
Descriptive:
<!--CODE START--!>
Dim objPerfData ' Define objPerfData Set objPerfData = ScriptContext.CreatePerfData() ' Set the empty object up objPerfData.SourceDomain = strSourceDomain ' Sets the domain name of the computer that_ ' is providing the performance data objPerfData.SourceComputer = strSourceComputer ' Sets the name of the computer from which_ ' the performance data was collected objPerfData.ObjectName = strObjectName ' Sets the name of the performance object_ ' for which the performance data was_ ' collected. Examples of performance objects_ ' are processes, sections of shared memory,_ ' and physical devices objPerfData.CounterName = strCounterName ' Sets the name of the performance_ ' counter used to report the performance data objPerfData.InstanceName = strInstanceName ' Sets the name of the performance counter_ ' instance used to report the performance data objPerfData.Value = numValue ' Sets the numeric value of the performance data objPerfData.SampleLocalTime = strSampleLocalTime ' Sets the local date and time that the_ ' performance data was collected objPerfData.SampleUTCTime = strSampleUTCTime ' Sets the date and time that the performance_ ' data was collected ScriptContext.Submit(objPerfData) ' Object sent to the MOM data stream
<!--CODE END--!>
Paste-able:
<!--CODE START--!>
Function CreateMOMPerfObject(strSourceDomain, strSourceComputer, _ strObjectName, strCounterName, strInstanceName, numValue, _ strSampleLocalTime, strSampleUTCTime) Dim objPerfData Set objPerfData = ScriptContext.CreatePerfData() objPerfData.SourceDomain = strSourceDomain ' optional objPerfData.SourceComputer = strSourceComputer ' optional objPerfData.ObjectName = strObjectName objPerfData.CounterName = strCounterName objPerfData.InstanceName = strInstanceName objPerfData.Value = numValue objPerfData.SampleLocalTime = strSampleLocalTime ' optional objPerfData.SampleUTCTime = strSampleUTCTime ' optional ScriptContext.Submit(objPerfData) Set CreateMOMPerfObject = objPerfData End Function
<!--CODE END--!>
Create a MOM Alert Data Object in a MOM .vbs Script
Descriptive:
<!--CODE START--!>
' Alert Severity Levels Const SUCCESS_ALERT_LEVEL = 10 Const INFO_ALERT_LEVEL = 20 Const WARNING_ALERT_LEVEL = 30 Const ERROR_ALERT_LEVEL = 40 Const CRITICAL_ERROR_ALERT_LEVEL = 50 Const SECURITY_ISSUE_ALERT_LEVEL = 60 Const SERVICE_UNAVAILABLE_ALERT_LEVEL = 70' Alert Resolution States ' Reference MOM Admin Console's global setting Alert Resolution states tab Const NEW_RESOLUTION_STATE = 0 Const ACK_RESOLUTION_STATE = 85 Const LEVEL1_RESOLUTION_STATE = 170 Const LEVEL2_RESOLUTION_STATE = 180 Const LEVEL3_RESOLUTION_STATE = 190 Const RESOLVED_RESOLUTION_STATE = 255 CreateMOMAlertObject(Success_Alert_Level, "Test Script", "Hi MOM!", "App7",_ "AD", "Test Script", "[unassigned]", New_Resolution_State) Function CreateMOMAlertObject(strAlertLevel, strAlertSource, strDescription,_ strComputer, strCompDomain, strName, strOwner, strResState, strComponent,_ strComponentInstance, strServerRole, strServerRoleInstance) ' Define everything Dim objAlertData Set objAlertData = ScriptContext.CreateAlert() ' Assign values to the Alert object properties objAlertData.AlertLevel = strAlertLevel ' Sets the severity of the alert, using ' one of the seven constants above ' These are often set at the top of the ' main code and passed here objAlertData.AlertSource = strAlertSource ' Optional. Sets the source of the alert, ' a user-defined name If no name is defined, ' the event source is typically used objAlertData.Description = strDescription ' Sets the description of the alert ' Typically the description of the event ' that generated the alert ' Ex.: = ScriptContext.Event.EventParameter(1) objAlertData.Computer = strComputer ' Sets the name of the computer ' that raised the alert ' Use only NetBIOS names! ' Ex.: = ScriptContext.Event.SourceComputer objAlertData.ComputerDomain = strCompDomain ' Sets the domain name of the computer ' that raised the alert ' Use only NetBIOS names! ' Ex.: = ScriptContext.Event.SourceDomain objAlertData.Name = strName ' Gets or sets the name of the rule ' that raised the alert ' Generaly the name of the rule ' that raised the alert ' Ex.: = ScriptContext.Alert.Name objAlertData.Owner = strOwner ' Gets or sets the name of the alert owner ' Someone responsible for tracking and ' resolving the alert ' Ex.: = "[unassigned]" objAlertData.ResolutionState = strResState ' Sets the resolution state of the ' alert, using one of the constants above ' These are often set at the top of the main code and passed here. ' State monitoring uses the ServerRole, ServerRoleInstance, Component, and ' ComponentInstance properties to determine a computer's overall state, and ' to precisely specify the cause of any problems. The ServerRoleInstance ' property specifies which service caused the alert - a computer can be running ' more than one instance of a type of service. The ComponentInstance property ' specifies which component within the service caused the alert. ' A service can contain more than one instance of a component. ' objAlertData.Component = strComponent ' Sets the type of service component ' that the alert is associated with ' objAlertData.ComponentInstance = strComponentInstance ' Sets the service component ' instance that the alert is associated with ' objAlertData.ServerRole = strServerRole ' Sets the service that the alert ' is associated with ' objAlertData.ServerRoleInstance = strServerRoleInstance ' Sets the specific ' service instance that the alert is associated with ' Insert the populated Alert into the MOM data stream Set CreateMOMAlertObject = objAlertData End Function
<!--CODE END--!>
Paste-able:
<!--CODE START--!>
Function CreateMOMAlertObject(strAlertLevel, strAlertSource,_ strDescription, strComputer, strCompDomain, strName) Dim objAlertData Set objAlertData = ScriptContext.CreateAlert() Const Success_Alert_Level = 10 Const Information_Alert_Level = 20 Const Warning_Alert_Level = 30 Const Error_Alert_Level = 40 Const Critical_Error_Alert_Level = 50 objAlertData.AlertLevel = strAlertLevel objAlertData.AlertSource = strAlertSource objAlertData.Description = strDescription objAlertData.Computer = strComputer objAlertData.ComputerDomain = strCompDomain objAlertData.Name = strName Set CreateMOMAlertObject = objAlertData End Function
<!--CODE END--!>