ClickATell is a SMS gateway supporting email to SMS, direct HTTP and other methods.
#!/bin/sh
# This function call the clickatell through HTTP instead of Email to SMS
# Print the help and exit.
dumphelp(){
echo "send_sms "
exit
}
# Check if number of parameter is 1. If not, print the help and exit.
if [ $# -ne 2 ]; then
dumphelp
fi
NAGIOSHOME=/usr/local/nagios
NAGIOSLOG=$NAGIOSHOME/var
SMSLOG=$NAGIOSLOG/sms.log
USER="XXXXXXX"
PASSWORD="XXXXXXX"
API_ID="XXXXXXXX"
PHONE=$1
MSG=$2
# As calling through HTTP instead of email to SMS, need to replace all space with +
MSG1=`echo $2 | sed "s/ /+/g"`
# Get the current log time
LOGTIME=`date "+%Y%m%d %H:%M:%S.%N"`
echo "$LOGTIME [To: $PHONE] [Msg: $MSG1]" >> $SMSLOG
wget -q -O /tmp/sms.html "http://api.clickatell.com/http/sendmsg?user=$USER&password=$PASSWORD&api_id=$API_ID&to=$PHONE&text=$MSG1"
- Add the following to command.cfg
# 'notify-host-by-sms' command definition
define command{
command_name notify-host-by-sms
command_line $USER1$/send_sms $CONTACTPAGER$ "$NOTIFICATIONTYPE$ $HOSTALIAS$ $HOSTSTATE$ [$HOSTOUTPUT$]"
}
# 'notify-service-by-sms' command definition
define command{
command_name notify-service-by-sms
command_line $USER1$/send_sms $CONTACTPAGER$ "$NOTIFICATIONTYPE$ $SERVICEDESC$ $HOSTALIAS$ $SERVICESTATE$ [$SERVICEOUTPUT$]"
}
- Add the generic-sms-contact to templates.cfg
define contact{
name generic-sms-contact ; The name of this contact template
service_notification_period 24x7 ; service notifications can be sent anytime
host_notification_period 24x7 ; host notifications can be sent anytime
service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
service_notification_commands notify-service-by-sms ; send service notifications via sms
host_notification_commands notify-host-by-sms ; send host notifications via sms
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}
- Add the following to contacts.cfg
# Define the person to receive the SMS
define contact{
contact_name SMS.XXX
use generic-sms-contact
alias System Admin
email AAA@bbb.ccc.com
pager 1234567890
}
# Define the SMS contact group
define contactgroup{
contactgroup_name SMS_ABCDE
alias Server Application Admin
members SMS.XXX
}
- Use the SMS_ABCDE in the contact_groups when you define the service/host.