---
title: How to enable SMS alerts in Nagios using AWS SNS
description: Nagios is a powerful management and monitoring system. It helps in identifying the IT infrastructure problems. It also helps in resolving the problem before they affect the infrastructure and create critical issues.
image: https://blog.e-zest.com/hubfs/blog-files/nagios.png
---

[![e-Zest logo\_An accion lab company\_Colour](https://blog.e-zest.com/hubfs/images/Logos%20with%20Tagline/Corporate/SVG/e-Zest%20logo_An%20accion%20lab%20company_Colour.svg "e-Zest logo_An accion lab company_Colour")](https://www.e-zest.com/)

- [WORK](https://www.e-zest.com/our-work)
- [SERVICES](https://www.e-zest.com/our-services) 
    - [Product Engineering](https://www.e-zest.com/digital-product-engineering-services)
    - [Enterprise Data Services](https://www.e-zest.com/enterprise-data-services)
    - [Digital Commerce](https://www.e-zest.com/digital-commerce-services)
    - [Digital Operations](https://www.e-zest.com/digital-operations)
    - [Digital Consulting](https://www.e-zest.com/digital-transformation-consulting-services)
    - [Digital Experience Design](https://www.e-zest.com/digital-experience-design)
- [INSIGHTS](https://blog.e-zest.com/)
- [CAREERS](https://www.e-zest.com/careers)
- [ENTERPRISE DATA SERVICES](https://www.e-zest.com/enterprise-data-services)
- [GENERATIVE AI](https://www.e-zest.com/generative-ai)
- [Healthcare](https://healthcare.e-zest.com)
- [Contact Us](https://www.e-zest.com/contact-us)

- ![Elevating Product Engineering with AI and ML](https://blog.e-zest.com/hubfs/Elevating%20Product%20Engineering%20with%20AI%20and%20ML.jpg)

  [BLOGS](https://blog.e-zest.com)
  
  #### Elevating Product Engineering with AI and ML

  As technology evolves and customer choices broaden, there is an increasing ...

  [Read more](https://blog.e-zest.com/elevating-product-engineering-with-ai-and-ml)
- ![e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024](https://blog.e-zest.com/hubfs/e-Zest%20%E2%80%93%20An%20Accion%20Labs%20Company%20-%20Gets%20Recognition%20as%20a%20Contender%20in%20the%20ISG%20Provider%20LensTM%20Study%20on%20Digital%20Engineering%20Services%202024.jpg)

  [NEWS](https://blog.e-zest.com/news)
  
  #### e-Zest – An Accion Labs Company gets Recognition as a Contender in the ISG Provider Lens™ Study on Digital Engineering Services 2024

  We are delighted to announce that e-Zest – An Accion Labs Company has been ...

  [Read more](https://blog.e-zest.com/news/e-zest-an-accion-labs-company-gets-recognition-as-a-contender-in-the-isg-provider-lens-study-on-digital-engineering-services-2024)
- ![e-Zest Solutions supports Digital Pune Mission](https://blog.e-zest.com/hubfs/blog-files/Digital%20Literacy%20Bus%20e-Zest.png)

  [CSR](https://blog.e-zest.com/csr)
  
  #### e-Zest Solutions supports Digital Pune Mission

  **Pune, India:** e-Zest Solutions, a leading digital technology innovation ...

  [Read more](https://blog.e-zest.com/csr/e-zest-solutions-supports-digital-pune-mission)

- [Work](https://www.e-zest.com/our-work)
- [Services](https://www.e-zest.com/our-services)
- [Insights](https://blog.e-zest.com)
- [Careers](https://www.e-zest.com/careers)
- [Enterprise Data](https://www.e-zest.com/enterprise-data-services)
- [Generative AI](https://www.e-zest.com/generative-ai)
- [Innovations](https://www.e-zest.com/innovations)
- [Healthcare](https://healthcare.e-zest.com)
- [About](https://www.e-zest.com/about-us)
- [Contact](https://www.e-zest.com/contact-us)

- [Blog](https://blog.e-zest.com/)
- [News](https://blog.e-zest.com/news)
- [CSR](https://blog.e-zest.com/csr)

- [![Linkedin Icon](https://blog.e-zest.com/hubfs/icons/linkedin_icon_white.svg)](https://www.linkedin.com/company/e-zest-solutions/)
- [![Twitter Icon](https://blog.e-zest.com/hubfs/twitter-logo-silhouette%20(5).svg)](https://twitter.com/ezest)
- [![Facebook Icon](https://blog.e-zest.com/hubfs/facebook-app-logo%20(4).svg)](https://www.facebook.com/61259256638)
- [![Instagram Icon](https://blog.e-zest.com/hubfs/instagram-logo%20(4).svg)](https://www.instagram.com/ezestsolutions/)
- [![Youtube Icon](https://blog.e-zest.com/hubfs/icons/youtube_icon_white.svg)](https://www.youtube.com/user/ezestcorporate)

[![Go to top icon](https://blog.e-zest.com/hubfs/AA%20Assets/top%20button.svg)](https://blog.e-zest.com/how-to-enable-sms-alerts-in-nagios-using-aws-sns#top)

Hit enter to search or ESC to close

Insights

e-Zest members share technology ideas to foster digital transformation.

- [Blog](https://blog.e-zest.com)
- [Whitepaper](https://blog.e-zest.com/whitepaper)
- [Playbook](https://blog.e-zest.com/playbook)
- [News](https://blog.e-zest.com/news)
- [Innovation](https://blog.e-zest.com/innovation)

# How to enable SMS alerts in Nagios using AWS SNS

[Anagha Thorat](https://blog.e-zest.com/author/anagha-thorat)  Feb 06, 2019

[AWS](https://blog.e-zest.com/topic/aws) [Amazon Linux](https://blog.e-zest.com/topic/amazon-linux) [AWS CLI](https://blog.e-zest.com/topic/aws-cli) [nagios](https://blog.e-zest.com/topic/nagios)

- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/how-to-enable-sms-alerts-in-nagios-using-aws-sns&title=&summary=&source=>
- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/how-to-enable-sms-alerts-in-nagios-using-aws-sns&text=How%20to%20enable%20SMS%20alerts%20in%20Nagios%20using%20AWS%20SNS>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/how-to-enable-sms-alerts-in-nagios-using-aws-sns>
- <https://www.instagram.com/ezestsolutions/?u=https://blog.e-zest.com/how-to-enable-sms-alerts-in-nagios-using-aws-sns>

Nagios is a powerful management and monitoring system. It helps in identifying the IT infrastructure problems. It also helps in resolving the problems before they affect the infrastructure and create critical issues.

One of the key components of Nagios is to alert before something breaks. Nagios sends e-mail alerts to recipients. But we cannot access the e-mails 24/7, we need some option where we have access to the device 24/7. The most convenient option would be SMS notifications. We will be integrating AWS SNS (Amazon Simple Notification Service) with Nagios to send SMS notifications for critical alerts. We will be using AWS CLI (AWS Command Line Interface) for enabling the SMS Alerts.

**Prerequisites:**  
OS: Amazon Linux  
AWS CLI Installed  
RAM: 3GB

**Check AWS CLI is installed**

To check if AWS CLI is installed hit the following command  
*aws --version*  
If it throws an error like command not found install AWS CLI then you can use the below command  
*pip install AWS CLI--upgrade --user*

**Create SNS topic on AWS console**

 Follow the following steps:

1. Log in to the AWS SNS Console
2. Click on ‘Create New Topic’
3. Enter the topic name and display name and click on ‘Create New Topic’
4. After creation of topic click on the topic
5. Click on ‘Create Subscription’
6. While creating the subscription select the protocol as ‘SMS’
7. Add mobile number as an endpoint
8. Click on ‘Create Subscription’

**Script to enable AWS SMS Alerts**  
Login to the Nagios Server

Create a file to write a script  
*vim /opt/smsalerts.sh*

Copy the following code in the file  
*#!/bin/bash*  
*export AWS\_DEFAULT\_REGION=us-east-1*  
*/usr/bin/aws sns publish --topic-arn arn:aws:sns:us-east-1:XXXXXXXXX:Nagios\_Notification --message "$\*"*  
*#EOF*

**Note:** edit the topic-arn in the above script  
Save the file.

**Define command to enable SMS alerts in Nagios**

Now edit the commands.cfg file of Nagios  
*vim /etc/Nagios/objects/commands.cfg*

Add the following lines to the end of file  
*define command{*  
 *command\_name notify-service-by-sns*  
 *command\_line /usr/bin/printf "%b" "\*\*\*\*\* Nagios \*\*\*\*\*\\nNotification Type: $NOTIFICATIONTYPE$\\nService: $SERVICEDESC$\\nHost: $HOSTALIAS$\\nAddress: $HOSTADDRESS$\\nState: $SERVICESTATE$\\nDate/Time: $LONGDATETIME$\\nAdditional Info:\\n$SERVICEOUTPUT$\\n" | xargs /opt/smsalerts.sh $1*  
*}*

*define command{*  
 *command\_name notify-host-by-sns*  
 *command\_line /usr/bin/printf "%b" "\*\*\*\*\* Nagios \*\*\*\*\*\\n\\nNotification Type: $NOTIFICATIONTYPE$\\nHost: $HOSTNAME$\\nState: $HOSTSTATE$\\nAddress: $HOSTADDRESS$\\nInfo: $HOSTOUTPUT$\\n\\nDate/Time: $LONGDATETIME$\\n" | xargs /opt/smsalerts.sh $1*  
 *}*

**Define contact to enable SMS Alerts**

Edit the templates.cfg  
Find the code where contact is defined. Add the command name for service\_notification\_commands and host\_notification\_commands. Refer below code for reference

![define-contact](https://blog.e-zest.com/hs-fs/hubfs/blog-files/define-contact.png?width=736&name=define-contact.png)   
**Restart the Nagios Service**

Hit the below command to restart the Nagios  
*'service Nagios restart'*

- <https://twitter.com/intent/tweet?source=https://blog.e-zest.com/how-to-enable-sms-alerts-in-nagios-using-aws-sns&text=How%20to%20enable%20SMS%20alerts%20in%20Nagios%20using%20AWS%20SNS>
- <https://www.facebook.com/sharer/sharer.php?u=https://blog.e-zest.com/how-to-enable-sms-alerts-in-nagios-using-aws-sns>
- <https://www.linkedin.com/shareArticle?mini=true&url=https://blog.e-zest.com/how-to-enable-sms-alerts-in-nagios-using-aws-sns&title=&summary=&source=>

### Similar Blog

[![AWS IoT - Now Migration is Quick and Easy](https://blog.e-zest.com/hubfs/Blog%20Graphic%20(AWS%20IoT%20migration)%20V5-05.jpg) AWS IoT - Now Migration is Quick and Easy AWS can help make your migration quick and easy Modern businesses employ Internet of Things (IoT) platforms to manage their ... By Mohini Wable Nov 22, 2022](https://blog.e-zest.com/aws-iot-now-migration-is-quick-and-easy)

[![3 Cloud-Native Trends That are Reshaping Our Businesses in 2022](https://blog.e-zest.com/hubfs/e-Newsletter-04.jpg) 3 Cloud-Native Trends That are Reshaping Our Businesses in 2022 The move to the cloud was a trend that was already making headways before the pandemic-led digital shift. But post-2020, the ... By Devendra Deshmukh Feb 22, 2022](https://blog.e-zest.com/3-cloud-native-trends-that-are-reshaping-our-businesses-in-2022)

[![AWS EC2 Assume Role with Terraform](https://blog.e-zest.com/hubfs/blog-files/AWS%20EC2%20Assume%20Role%20with%20Terraform.jpg) AWS EC2 Assume Role with Terraform Nowadays, it is an ideal practice to keep different AWS accounts for IAM users and a different account for running production ... By Vaibhav Khalane Jan 28, 2020](https://blog.e-zest.com/aws-ec2-assume-role-with-terraform)

[Service cloud Einstein to integrate with Amazon Connect Previously, enterprises were highly dependent on paper documentations. Later a huge computer revolution encountered, which ... By Nidhi Thakkar Apr 17, 2017](https://blog.e-zest.com/service-cloud-einstein-to-integrate-with-amazon-connect)

[![Installing and setting HDFS cluster through Ambari](https://blog.e-zest.com/hubfs/blog-files/Installing%20and%20setting%20HDFS%20cluster%20through%20Ambari-181205.png) Installing and setting HDFS cluster through Ambari Apache Ambari is an open source management tool/platform for managing, provisioning, securing and monitoring the Hadoop Cluster. ... By Anagha Thorat Oct 31, 2018](https://blog.e-zest.com/installing-and-setting-hdfs-cluster-through-ambari)

[SSL Encryption using Let’s Encrypt on AWS EC2 Amazon Linux **What is Let’s Encrypt:** By Anagha Thorat Feb 27, 2017](https://blog.e-zest.com/ssl-encryption-using-lets-encrypt-on-aws-ec2-amazon-linux)

[Troubleshooting with Nginx - **Introduction** What is Nginx? By Anagha Thorat Nov 22, 2016](https://blog.e-zest.com/troubleshooting-with-nginx)

## Helping Organizations Thrive in the Digital Age

[Contact Us](https://www.e-zest.com/contact-us)

- [About](https://www.e-zest.com/about-us)
- [Services](https://www.e-zest.com/our-services)
- [Work](https://www.e-zest.com/our-work)
- [Insights](https://blog.e-zest.com/)
- [Healthcare](https://healthcare.e-zest.com/)
- [Accion Labs](https://www.accionlabs.com/)

- <https://www.linkedin.com/company/e-zest-solutions/>
- <https://twitter.com/ezest>
- <https://www.facebook.com/eZest/>
- <https://www.instagram.com/ezestsolutions/>
- <https://www.youtube.com/user/ezestcorporate>

- Dallas
- Detroit
- Hannover
- Vienna
- London
- Pune

 © 2025 e-Zest Solutions

- [Privacy Policy](https://www.e-zest.com/privacypolicy)
- [Cookie Policy](https://www.e-zest.com/cookie-policy)

 Contact us

 Contact us

e-Zest is a leading digital innovation partner for enterprises and technology companies that utilizes emerging technologies for creating engaging customers experiences. Being a customer-focused and technology-driven company, it always helps clients in crafting holistic business value for their software development efforts. It offers software development and consulting services for cloud computing, enterprise mobility, big data and analytics, user experience and digital commerce.