Sorry for the lag in posting. I’ve been on the road.
As mentioned, I post when I find something interesting, and we had a recent customer request that was very interesting to me. They have multiple internal mail servers for different purposes, and want to be able to send email notifications to the right recipient at the right server for the right alert.
As with so much other stuff, the OpsMgr console doesn’t allow this. The best you get is primary and failover servers.
But email servers are just write actions, and email notifications are just workflows. Seems like this should be doable.
It is. Here’s how you do it using the authoring console.
First, import the Microsoft.SystemCenter.Notifications.Internal MP into the authoring console
Create a new composite write action that will be your SMTP server. I’m going to call it My.Second.Smtp.Server for the purpose of this howto. Use either the Microsoft.SystemCenter.Notification.NotificationActionAccount or another appropriate account if you have one. Name the Write Action whatever you want. It only has one module: Microsoft.SystemCenter.Notification.SmtpNotificationTransportAction. There is no built in page to edit this type, so you’ll have to drop into XML. Configure as shown:
|<Configuration p1:noNamespaceSchemaLocation="C:\Documents and Settings\Administrator\Local Settings\Temp\NotificationAction – Microsoft.SystemCenter.Notification.SmtpNotificationTransportAction.xsd" xmlns:p1="http://www.w3.org/2001/XMLSchema-instance">
That’s your endpoint.
Next, create another composite write action. I’m going to call it Send.Email.To.Second.Server. This one is where you configure the message format, then send the information to the endpoint My.Second.Smtp.Server. This one has a ConditionDetection module of type Microsoft.SystemCenter.Notification.SmtpNotificationContentGenerator and the My.Second.Smtp.Server module.
Again, there’s no configuration UI for the ConditionDetection module, so you have to use XML. Configure as shown:
|<Configuration p1:noNamespaceSchemaLocation="C:\Documents and Settings\Administrator\Local Settings\Temp\ContentGenerator – Microsoft.SystemCenter.Notification.SmtpNotificationContentGenerator.xsd" xmlns:p1="http://www.w3.org/2001/XMLSchema-instance">
<Subject>Alert: $Data/Context/DataItem/AlertName$ Priority: $Data/Context/DataItem/Priority$ ResolutionState: $Data/Context/DataItem/ResolutionStateName$</Subject>
<Body>Your message here. You can use all the $Data/Context…$ fields you want. Since you are editing the right MP, have a look at the DefaultSmtpAction write action module right there in your authoring console to see what the default configuration looks like</Body>
The My.Second.Smtp.Server module has nothing to configure.
You now have a Write Action that can be used in a rule workflow to send email. At this point, go ahead and export your management pack back into OpsMgr. You could create a rule manually, but it’s easier to let the UI do a bunch of rule stuff for you such as figuring out the GUID of your recipient. You can also take advantage of the PowerShell script to create subscriptions for specific rules. (If you create your own rule, make sure to set the Category to "Notification")
Create a new notification as you normally would. Once you’ve done that, re-import the Notification management pack back into the Authoring Console.
Find the rule you just created in the Health Model – Rules section. It’s going to have some awful GUID name that starts with "Subscription…".
Remove the Write Action and replace it with Send.Email.To.Second.Server.
Save changes and export the management pack back into OpsMgr. The notification rule will now send email to your configured recipient via the second SMTP server.
If you have an easier way to do this, please let me know. This was a quick-and-dirty proof of concept, and I have a feeling in my gut that there’s a more elegant way to do it, and possible a more elegant way to maintain it. All this importing and exporting is more than should be necessary. I just don’t have time to refine it right now…