Glenn Wilson
Guest
|
Posted:
Thu Jan 06, 2005 5:31 am Post subject:
Creating Custom Scripts Step by Step |
|
|
I have to work on some custom scripts for MOM, these scripts are for
monitoring internal Database systems. For example we have an internally
written applications that writes messages to a messagelog database table. I
need to configure a monitoring action to collect some data from this data,
process some rules, and then decide wether to alert or not, and what type of
alert to send ( crit, warning, information, error, and such)
What I am looking for is a simple tutorial on witing scripts for MOM, then
an article on how to set it up..
Can some one send me to a link or in a direction to find what I am looking
for. |
|
Guest
|
Posted:
Fri Jan 07, 2005 1:53 am Post subject:
Creating Custom Scripts Step by Step |
|
|
OK,
1. Write a script not for MOM in order to get the data
from you database table.
Create a simple VBS and check if you get the right data.
2. In order to generate alert first create an event
Using this function:
and call this function for example:
Const EVENT_SOURCE = "My Application"
'Event Type Constants
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4
Const SUCCESS = 0
Const ERROR = 1
Const WARNING = 2
Const INFORMATION = 4
Const AUDIT_SUCCESS = 8
Const AUDIT_FAILURE = 16
Const EVENTID = 998877
MsgEvent = "We have a problem"
CreateEvent EVENT_SOURCE, EVENTID ,EVENT_TYPE_WARNING,
MsgEvent ,strComputerName
'==========================================================
===============
' Insert event to MOM all other events
'==========================================================
===============
Sub CreateEvent(strSource, lngEventID, lngEventType,
strMsg, strSrcComputer)
Const MAX_EVENT_DESCRIPTION_LENGTH = 3450
Dim oNewEvent
' Create a new event
Set oNewEvent = ScriptContext.CreateEvent
' Set event properties
oNewEvent.Message = Left(strMsg,
MAX_EVENT_DESCRIPTION_LENGTH)
oNewEvent.EventNumber = lngEventID
oNewEvent.EventType = lngEventType
oNewEvent.EventSource = strSource
If strSrcComputer <> "" Then
oNewEvent.SourceComputer = strSrcComputer
oNewEvent.LoggingComputer = strSrcComputer
End If
' Submit the event
ScriptContext.Submit oNewEvent
Set oNewEvent = Nothing
End Sub
'==========================================================
===============
' Insert event to event log
'==========================================================
===============
sub LogEvent(nSeverity, sDescription, sComputer)
Dim oShell
Dim bSuccess
set oShell = CreateObject("WScript.Shell")
bSuccess = oShell.LogEvent(nSeverity, sDescription,
sComputer)
set oShell = Nothing
end sub
3. Create a new Event rule and the provider is "Script-
generated Data and in Criteria you can write with event id
998877
You can also using parameter for each rule using
'Get Parameters
Set oParams = ScriptContext.Parameters
str1 = oParams.get("mystr1")
str2 = oParams.get("mystr2")
Hop this help you
Idan
| Quote: | -----Original Message-----
I have to work on some custom scripts for MOM, these
scripts are for
monitoring internal Database systems. For example we have
an internally
written applications that writes messages to a messagelog
database table. I
need to configure a monitoring action to collect some
data from this data,
process some rules, and then decide wether to alert or
not, and what type of
alert to send ( crit, warning, information, error, and
such)
What I am looking for is a simple tutorial on witing
scripts for MOM, then
an article on how to set it up..
Can some one send me to a link or in a direction to find
what I am looking
for.
.
|
|
|