Page 1 of 2
Send SMS Messages with Nagios
Posted: Wed Jun 25, 2014 4:13 pm
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.
Re: Send SMS Messages with Nagios
Posted: Thu Jun 26, 2014 2:00 am
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.
Re: Send SMS Messages with Nagios
Posted: Thu Jun 26, 2014 7:24 am
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?
Re: Send SMS Messages with Nagios
Posted: Thu Jun 26, 2014 9:42 am
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:
[email protected]
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.
Re: Send SMS Messages with Nagios
Posted: Thu Jun 26, 2014 10:54 am
by billperrotta
ok well I have core Where can I find a step by step guide to set it up?
Re: Send SMS Messages with Nagios
Posted: Thu Jun 26, 2014 11:12 am
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.
Re: Send SMS Messages with Nagios
Posted: Thu Jun 26, 2014 2:08 pm
by billperrotta
Is there a way to limited the nagios sms alerts to only high priority alerts?
Re: Send SMS Messages with Nagios
Posted: Thu Jun 26, 2014 2:18 pm
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.
Re: Send SMS Messages with Nagios
Posted: Wed Jul 16, 2014 9:03 am
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 ***'"
Re: Send SMS Messages with Nagios
Posted: Wed Jul 16, 2014 9:12 am
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?