Changing Alert Resolution State automatically

If you need to change the Resolution State when a new Alert appears, or change the status of an alert from a specific source or a given period of time, it could be done with a script. The script will be called by creating a Notification. Often you specify a SMTP, SMS or IM as a Channel but lets instead call a script – In this sample I will use a Powershell script to change new alerts Resolution state to the “Print Guys”.
Lets start with creating a Command Notification Channel – Give it a name like this one:
Start your Operations Manager Console, choose Administration and right click [Notifications] like….:

New Channel

image
Click new Command…
image
Click [Next]
image
And [Finish]

New Alert State

To create a new alert
Choose Settings and Properties on Alerts.
image
Click [New] and add a New Resolution State, give it an ID which will be used for your script to change a default alert value of 0 New.
In generel try to categorize your Alert ID it could be you one day would create a query of all alerts id between 90-100. So try to create your alerts in a value range like:
Hardware ID 31-60
Software ID 61-100
SNMP ID 101-110
image
Create your Script – This sample script could be divided in three parts – First you parameters – could drop them – but it’s easier to read the changes and reuse the script. Second part is your initialization of your Powershell Provider so you are able to run the script from a powershell shell. Last part is changing all resolution states of all alerts which is included in your clause.
Paste this script into your file – in this sample it is the c:\scripts\PrintGuys.ps1 and save close it.
*********************** Script ************************
$rootMS = “STO-RMS”
$ResolutionState = 90
#Initializing the Ops Mgr 2007 Powershell provider
add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client” ;
set-location “OperationsManagerMonitoring::” ;
new-managementGroupConnection -ConnectionString:$rootMS ;
set-location $rootMS ;
$Alerts = get-alert -criteria ‘Name = ”Windows Service Stopped”’ | Where {$_.ResolutionState -eq 0 -and $_.Description -like ‘The ”Print Spooler” service on computer STO-RMS.contoso.msft has stopped running’}
foreach($Alert in $Alerts)
{
$Alert.ResolutionState = $ResolutionState
$Alert.Update(“Resolution State changed automatically by the notificator”)
}
The last thing is to create a Subscription which is running everytime your alert show up. This sample will change the Windows Service Stopped Alert.
image
Right Click your Alert and choose: Create Notification Subscription
image
Give it a Name and click [Next]
image
Remember your Wildcards when you use Description
image
Add a Subscriber address – Call it e.g. Script Notification
image
image
image
Click [Finish] and Voila – from now on your Alerts are automatically being changed to your Resolution States.
image
Try and work with different script and Alerts – OpsMgr Rules ..;-)

Comments (6):

  1. Dipan says:

    Hi Kare

    Thanks for the article, excellent and informative. I am trying to do something similar and would appreciate very much if you are able to provide any assistance. I am trying to monitor diskspace and the default website on a couple of servers using SCOM 2012. I want to change the new alert resolution. I have created a custom alert resolution state with an ID of 19. I wanted to know the following:
    1) Do you suggest I create two IDs for these two monitoring activities and hence two scripts with the resolution ID?
    2) Do you think that the script will work with SCOM 2012?
    3) If it does work then should I change the script as follows for IIS. What should be the script be like for disk space:
    *********************** Script ************************
    $rootMS = “STO-RMS”
    $ResolutionState = 19
    #Initializing the Ops Mgr 2007 Powershell provider
    add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client” ;
    set-location “OperationsManagerMonitoring::” ;
    new-managementGroupConnection -ConnectionString:$rootMS ;
    set-location $rootMS ;
    $Alerts = get-alert -criteria ‘Name = ”IIS 7 Web Site is unavailable”’ | Where {$_.ResolutionState -eq 0 -and $_.Description -like ‘The IIS 7 web site named Default Web Site on 1SOLARWINDS2.mediamonitors.com.au is unavailable’}
    foreach($Alert in $Alerts)
    {
    $Alert.ResolutionState = $ResolutionState
    $Alert.Update(“Resolution State changed automatically by the notificator”)
    }

    I am a newbie to the world of powershell and to SCOM. Any help will be greatly appreciated.

    Regards,

  2. Thank you for share this knowledge. What i am trying to find is – How to calculate the time from when an alert is rised in status new to the time that is moved in another status for example Assigned to Engineering.
    Regards Pencho

  3. Sibyl says:

    There can be ladies in hijab, in pants and in shorts.

    my blog – m88 (Sibyl)

  4. If some one wishes to be updated with latest technologies therefore he must be go to see this web page and be up to
    date daily.

  5. Hey there I am so excited I found your blog page, I really found you by error,
    while I was browsing on Askjeeve for something else, Anyhow I am
    here now and would just like to say kudos for a marvelous
    post and a all round interesting blog (I also love the theme/design), I don’t have time to look over it all at the moment but I have saved
    it and also added your RSS feeds, so when I have time I will be back to
    read more, Please do keep up the superb b.

  6. No matter if some one searches for his required thing, therefore he/she needs to be available that in detail, thus that thing
    is maintained over here.

Leave a Reply