Send Notifications with Amazon SES

Hello together,
i want to configure CheckMK to send the default HTML Mails via API from Amazon SES.

Sending an Email via HTTPS API is quite Simple. Just a few Lines of Code and the pip Extension boto3.

Reason: Mails can be sent out directly over https and it usually works without opening Ports on the Firewall. It would open the way to deploy checkmk on any customer site and allowing to send Mails when https port 443 to the internet is reachable.

Is there any way to use the default Template from CheckMK for Sending Mails or do i really have to program my own Notification Script for my own including the whole E-Mail Template?

You have to create a custom notification script for it. In the Notification documentation we have an example to create notification scripts. Other than that you can have a look at other notification scripts like Servicenow and get an idea. The scripts are located under ~/share/check_mk/notifications.

Thank you for the answer @chauhan_sudhir .

Is it possible to make a copy of the original Mailing Script mail.py and the wato file (dont know which one it is).

I want to use the original Mailing format of checkmk Enterprise and just want to develop a new Sending Method to let CheckMK use Amazon SES over API as Method.

Yes, this is possible. See Notifications - via Email, SMS, Ticketsystems and more

Hello @chauhan_sudhir ,

i copied the mail file and created a new File Called “mailses”

What do i have to do to copy the Wato Config for this Notification, to make the Configurable Variables Available for my copied notification plugin?

I want a copy of the Original Mail Plugin including all Features the Original HTML-Mail of CheckMK offers. I just modified the copied mail.py and added the Feature to send the mail over the Amazon-SES Api.

image

Hi again @chauhan_sudhir,

i got it working.
I can send mails with the copy of original HTML E-Mail Script. Its quite easy to use with amazon.

I just have a problem with the Feature
“Send seperate notifications to every recipient”

Because the module Names are hardcoded in the notify.py

                split_contexts = (
                    plugin_name not in ["", "mail", "asciimail", "slack"] or
                    # params can be a list (e.g. for custom notificatios)
                    params.get("disable_multiplexing") or bulk)

My new Module has the Name “mailses”

How can i add the module to the this file without hardcoding this file? It would get overwritten with every checkmk Update.

The Problem now is, that every notification gets send seperately and not together.

Glad to hear that it works.

You can try importing the part from notify.py with:
from cmk.base.notify import _process_notifications

than you can add _process_notifications() to your script into a patched function and change the lines in question.

def _process_notifications_patched(raw_context: EventContext, notifications: Notifications,
                           num_rule_matches: int, analyse: bool) -> List[NotifyPluginInfo]:
    plugin_info = []
    ...

After changing you can assign this patch to _process_notifications in the same script
_process_notifications = _process_notifications_patched

This is just a rough guess but worth a try.