Sending SMS notifications from the monitoring service using Amazon SNS (part 2)

Michalina Staszewska Michalina Staszewska

In the first part of the article, which you can find here: Amazon SNS part. 1, I showed how to prepare Amazon SNS (Simple Notification Service) to send notifications from the Icinga 2 monitoring system. We configured the access policy and user in IAM. In this section, we will proceed to set the parameters of the server with Icinga2 and start the service.

Configure server with Icinga 2 to send SMS notifications

To send an SMS message from Amazon Web Services we will use the dedicated Boto3 SDK toolkit for the Python language. You can find all available SDK options for other programming languages at

Installing and configuring AWS SDK Boto3 for the Python language

Installing Boto3 is not complicated. Usually, issue one of the commands in Linux:

pip install boto3 

If you encounter a problem, contact us using the form for help or check the instructions on the AWS website:

After installing the package, edit the /root/.boto file Then enter the credentials you have from creating the IAM user. Check the code below, which is an example. This is what the contents of the file should look like. In it, you should provide your own access credentials.

ec2_region_name = us-east-1
aws_access_key_id = AK23........6FQ
aws_secret_access_key = 4rc3..........P63cu

Proper handling of notifications requires writing a custom script to send SMS messages of any content. For the sake of example, I’ve included a script below, allowing you to send messages.

#!/usr/bin/env python
import sys
import boto3
message = sys.argv[1:]
client = boto3.client('sns', region_name='us-east-1')
message_string = ', '.join(message)
response = client.publish(
TopicArn = 'arn:aws:sns:us-east-1:ACCOUNT_ID:Icingaweb2',
Message = message_string

Hooking up to the Icinga 2 system

Let’s start with the configuration of the Icinga 2 system, which is used to send SMS notifications via a specific script.
An example command in Icinga 2 might look like the following:

object NotificationCommand "snsapi-host-notification" {
import "plugin-notification-command"
command = [ SysconfDir + "/icinga2/scripts/", "$host.state$ $$
$icinga.short_date_time$ output $host.output$" ]

Create a notification to be assigned to each host with enabled notifications named “pagersns”.

apply Notification "sns-icingaadmins" to Host {
import "snsapi-host-notification"
user_groups = host.vars.notification.pagersns.groups
users = host.vars.notification.pagersns.users
assign where host.vars.notification.pagersns

The template for the notification that is used by the assignment of the above notification:

template Notification "snsapi-host-notification" {
command = "snsapi-host-notification"
states = [ Up, Down ]
types = [ Problem, Acknowledgement, Recovery, Custom ]
period = "24x7"

For the correct assignment of the previously mentioned notification, the following code must also be included in the host configuration.

vars.notification["pagersns"] = {
groups = [ "snsapi-admins" ]


Step by step, I described how to configure the SNS service, the process of creating a new IAM user with limited access to the designated service, and the configuration of the Icinga 2 monitoring system, which is used to send SMS notifications.

The article is long, but this is only a part of the possibilities we can take advantage of using Icinga 2’s SMS and monitoring service. However, it’s an ideal start to begin your saga with AWS services, especially the Amazon Simple Notification Service.

Remember! AWS SNS is not just about SMS, it is also about email notifications or HTTP/S protocols. You can use the service in many ways, find the right direction and act.

If you have questions, go ahead. Fill out the form, we will talk about the possibility of implementing AWS SNS in your organization.


Do you have questions? Get in touch with us