Create SMS Media Type using AWS SNS

Video Lecture

Create SMS Media Type using AWS SNS Create SMS Media Type using AWS SNS

Description

See the Video for the detailed instructions and to see the working example.

  1. Log onto your AWS account and create an IAM user, add it to a group and give it the AmazonSNSFullAccess permission.
  2. Take note of the Access and Secret keys.
  3. Visit the SNS admin page in AWS, press the Start with an overview link.
  4. Select the link Text messaging (SMS)
  5. Edit Text messaging preferences to your desired settings, plus set a default Sender ID of Zabbix
  6. SSH onto the Zabbix server and run sudo apt install awscli
  7. Create a new file called sendsms.sh in the Zabbix alertscripts folder. The alertscripts folder is usually located at /usr/lib/zabbix/alertscripts. Check the /etc/zabbix/zabbix_server.conf file to be sure.
  8. Copy the text below into the new file replacing the placeholders with your AWS access, secret and region values.
1
2
3
4
5
6
7
8
#!/usr/bin/env bash
export AWS_ACCESS_KEY_ID=**your_access_key**
export AWS_SECRET_ACCESS_KEY=**your_access_secret**
export AWS_DEFAULT_REGION=**your_region**

aws sns publish \
  --message "$2" \
  --phone-number $1
  1. Allow sendsms.sh execute access using sudo chmod a+x sendsms.sh
  2. Test it from the bash prompt using ./sendsms.sh +012345678 "Your Message" replacing +012345678 with your own mobile number.
  3. Go into the Zabbix UI and edit the SMS media type to use script
  4. Select the script to be sendsms.sh
  5. Add {ALERT.SENDTO} and {ALERT.MESSAGE} as parameters
  6. Save and Test

Troubleshooting

If you get an error "no message for media type", then go into the Media type settings, and then its Message Templates tab and then add the Problem and Problem Recovery templates if they don't already exist, and then update.

AWS SNS SMS Pricing

Request AWS SMS Limit Increase