Create SMS Media Type using AWS SNS
Video Lecture
Description
See the Video for the detailed instructions and to see the working example.
- Log onto your AWS account and create an IAM user, add it to a group and give it the AmazonSNSFullAccess permission.
- Take note of the Access and Secret keys.
- Visit the SNS admin page in AWS, press the Start with an overview link.
- Select the link Text messaging (SMS)
- Edit Text messaging preferences to your desired settings, plus set a default Sender ID of Zabbix
- SSH onto the Zabbix server and run
sudo apt install awscli
- 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. - 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
- Allow
sendsms.sh
execute access usingsudo chmod a+x sendsms.sh
- Test it from the bash prompt using
./sendsms.sh +012345678 "Your Message"
replacing +012345678 with your own mobile number. - Go into the Zabbix UI and edit the SMS media type to use script
- Select the script to be sendsms.sh
- Add {ALERT.SENDTO} and {ALERT.MESSAGE} as parameters
- 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.
Useful Links
Request AWS SMS Limit Increase