In MOM 2005 you may have found that it is easy to set up a notification when a service goes down and comes back up, but what if you wanted to get an alert every so often while the service was down until it came back up?
This is something that is much easier to do in SCOM 2007, but if you haven’t upgraded to this version yet, you can still make it work with a little bit of effort.
The following gives an example of how you can:
The first thing you will need to do is go into the Scripts section of the Administration Console and create a new Script. Give it a descriptive name, leave the Language field as the default (VBScript) and paste the following code into the source code area:
'miory 11/19/2007 'Creates MOM Event 12345 if the Print Spooler (Spooler) service is not running strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colRunningServices = objWMIService.ExecQuery _ ("Select * from Win32_Service where Name='Spooler'") For Each objService in colRunningServices If objService.State <> "Running" Then CreateError "Print Spooler not Running" End If Next Function CreateError(ByVal sMessage) On Error Resume Next Dim oScriptErrorEvent Set oScriptErrorEvent = ScriptContext.CreateEvent() With oScriptErrorEvent .EventNumber = 12345 .EventType = EVENT_TYPE_ERROR .Message = sMessage .SetEventParameter """PRINT SPOOLER SERVICE""" .SetEventParameter sMessage End With ScriptContext.Submit oScriptErrorEvent ScriptContext.Echo "ThrowScriptError('" & sMessage & "')" End Function ‘End Script
You do not need to specify any parameters for the script, so you can just click Finish.
Create a new rule group.
In that new rule group, create the following rules:
To complete the changes, just right-click on Management Packs and click Commit Configuration Change.
And that’s it! Hope this helps.
Mike Ory