Send SMS Messages with Nagios

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
billperrotta
Posts: 115
Joined: Fri Feb 21, 2014 11:44 am

Send SMS Messages with Nagios

Post by billperrotta »

I already have Nagios sending email alerts.
I was just wondering how to go about sending sms text alerts.
I don't want to break anything but want to know step by step how to make it also send sms alerts.
chris.fixter
Posts: 22
Joined: Wed Jun 18, 2014 4:15 am

Re: Send SMS Messages with Nagios

Post by chris.fixter »

in a nutshell, you need to :
1. get an SMS provider and their API url.
2. create new commands for SMS host notification and SMS service notification. Most likely this is similar to mail notification command but it uses wget to call SMS api.
3. change the notification commands defined in contacts to use your new command.
billperrotta
Posts: 115
Joined: Fri Feb 21, 2014 11:44 am

Re: Send SMS Messages with Nagios

Post by billperrotta »

Not to sound stupid but how do I get an sms provider?

Do I have to sign up for one is there a fee?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Send SMS Messages with Nagios

Post by tmcdonald »

It might not be that difficult. Most cell phones can receive text messages via email. For example on Verizon, you can send an email to your phone number like so:

15551234567@vtext.com

That's how Nagios XI does it, and I have sent SMS to my phone from the command line so Core should handle it just fine.
Former Nagios employee
billperrotta
Posts: 115
Joined: Fri Feb 21, 2014 11:44 am

Re: Send SMS Messages with Nagios

Post by billperrotta »

ok well I have core Where can I find a step by step guide to set it up?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Send SMS Messages with Nagios

Post by tmcdonald »

http://nagios.sourceforge.net/docs/3_0/ ... ml#contact

I would create a separate contact for SMS than you have for emails, then just add "-sms" to the end of the contact name. Set the address as the proper <phone number>@<carrier> email address and it should work.
Former Nagios employee
billperrotta
Posts: 115
Joined: Fri Feb 21, 2014 11:44 am

Re: Send SMS Messages with Nagios

Post by billperrotta »

Is there a way to limited the nagios sms alerts to only high priority alerts?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Send SMS Messages with Nagios

Post by tmcdonald »

That really depends on what you mean by high-priority. You can set that contact (the sms-only one) to only receive alerts for critical issues by setting service_notification_options and host_notification_options to "c" only.
Former Nagios employee
billperrotta
Posts: 115
Joined: Fri Feb 21, 2014 11:44 am

Re: Send SMS Messages with Nagios

Post by billperrotta »

Will this tutorial below work on Suse Linux? this looks like a Debian example but I like the simplicity

Code: Select all

1) Create an API in clicatel gateway service

They are providing lots of methods to send sms through their gateway like https, smtp etc. I selected http and create the http API . Its pretty easy with their panel.

2)  Define New Command in commands.cfg

# host-notify-by-sms command definition
 define command{
 command_name host-notify-by-sms
 command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | wget "http://api.clickatell.com/http/sendmsg?user=clicatel-user-name&password=password&&api_id=XXXXX&to=$CONTACTEMAIL$&text='** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ @ $LONGDATETIME$ **'"
 }
# service-notify-by-sms command definition

define command{
 command_name service-notify-by-sms
 command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$ \nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | wget "http://api.clickatell.com/http/sendmsg?user=clickatel-user-name&password=password&api_id=XXXXX&to=$CONTACTEMAIL$&text='** $NOTIFICATIONTYPE$ Service Alert: $SERVICEDESC$ on $HOSTNAME$ State: $SERVICESTATE$ @ $LONGDATETIME$ **'"
 }
3) Use new command in contacts.cfg

define contact{
contact_name                    admin
alias                                  Adminlogs
service_notification_period     24×7
host_notification_period        24×7
service_notification_options    c,r
host_notification_options         d,r
service_notification_commands   service-notify-by-sms
host_notification_commands      host-notify-by-sms
email                           651234567
}

4) Verify nagios configuaration

nagios -v /etc/nagios/nagios.cfg

5) Restart nagios

6) Test and Verify new command

wget "http://api.clickatell.com/http/sendmsg?user=clicatel-user-name&password=password&&api_id=XXXXX&to= 651234567&text=' *** Welcome to adminlogs.info ***'" 
billperrotta
Posts: 115
Joined: Fri Feb 21, 2014 11:44 am

Re: Send SMS Messages with Nagios

Post by billperrotta »

no sure what these alert levels mean= service_notification_options c,r
host_notification_options d,r

Thinking if i only use c after each it will only send critical alerts?
Locked