O R G A N I C / F E R T I L I Z E R: mom: good resolutions are ...

Oct 12, 2006

mom: good resolutions are ...

...simply checks that men draw on a bank where they have no account.

so with that in mind, since there are obviously no good resolutions... don't you wish mom 2005 came with some manner of auto-resolving alerts? this has been something that has annoyed me for quite some time. i don't see the purpose of letting alerts linger in the wild for the expanse of eternity when most administrators don't bother using the mom console. they just want stuff in their mailbox.

here's a little script to do just that. i just took the scripts you can find all over the internet for resolving all alerts and added a date check so that only things over 5 days old are resolved. running this once a day by scheduled task helps keep things clean. the other benefit is that once the alert is resolved, the suppression goes away and notification fires again if the same problem is detected. just make sure to run it on the mom server.

if you want to change it to look for things even older than 5 days, modify this line:

If DateDifference(CDate(WMIDateStringToDate(objitem.TimeofFirstEvent))) > 5 Then 

change the value "5" to whatever amount days old you want. here's the script.


id = 255
Set objMOM = GetObject("winmgmts:!root\mom")
Set colItems = objMOM.ExecQuery("Select * from MSFT_alert where ResolutionState <> " & id & "",,48)

For Each objItem in colItems
    If DateDifference(CDate(WMIDateStringToDate(objitem.TimeofFirstEvent))) > 5 Then
        WScript.Echo objitem.name
     End If

Function WMIDateStringToDate(dtmDate)
    WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
    Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
    & " " & Mid(dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function

Function DateDifference(myDate)
    DateDifference = DateDiff("d",myDate,Now)
End Function

Sub ResolveAlertObject(objItem)
    If (Not(objItem Is Nothing)) Then
        If (objItem.ResolutionState <> id) Then
            objItem.ResolutionState = id
            Call objItem.Put_
        End If
    End If
End Sub