What you will learn
In this article, you will learn how to install kannel server on Debian and integrate it to a Nagios server for sms notifications. We asume that the reader already has a working Nagios server and we will focus on Kannel installation and its integration with Nagios.
Requirements
- Privileged access to your Debian server
- SMPP account or USB modem
- A Nagios server
- Privileged access to your Nagios server
Difficulty
MEDIUM
Conventions
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo
command
$ – requires given linux commands to be executed as a regular non-privileged user
Setting up Kannel

Install Kannel
The installation of kannel is simply done through apt-get
command:
# apt-get install kannel
Initial configuration
After having installed kannel, we will put in place an initial configuration before going further.
Let’s backup the default configuration file and create ours.
$ cd /etc/kannel/ # mv kannel.conf kannel.conf.bak # touch kannel.conf
Now let’s open the configuration file
# vi /etc/kannel/kannel.conf
And fill it with the following content
# CORE group = core admin-port = 13000 admin-password = [password for kannel admin] status-password = [password to get kannel status] wdp-interface-name = "*" log-file = "/var/log/kannel/kannel.log" log-level = 0 access-log = "/var/log/kannel/access.log" smsbox-port = 13001 # SMSBOX SETUP group = smsbox bearerbox-host = 127.0.0.1 sendsms-port = 13002 log-file = "/var/log/kannel/smsbox.log" # SENDING SMS group = sendsms-user username = [username for sending sms] password = [password for sending sms]
Switch Kannel to smsbox mode
By default Kannel works as a wapbox
, but in our case we want it to function as smsbox
.
To do so, we will edit /etc/default/kannel
# vi /etc/default/kannel
Comment START_WAPBOX=1
and uncomment START_SMSBOX=1
#START_WAPBOX=1 START_SMSBOX=1
Create a SMSC
For Kannel to be able to send text messages, it must use a SMSC
(Short Message Service Center). Thus we need to create a SMSC configuration.
Using a SMPP account
If we want to send sms via a SMPP
account, then we will add the following lines to /etc/kannel/kannel.conf
:
# SMSC group = smsc smsc = smpp smsc-id = smsc1 system-type = "VMA" host = xxxx.xxxx.xxxx.xxxx port = xxxx smsc-username = "username" smsc-password = "password"
Please adapt the configuration, using the values that your provider has given to you.
Using a USB modem
If we want to send sms via a USB modem, then we need to install wvdial
:
# apt-get install wvdial
After installation, we will run wvdialconf
to detect the USB modem and generate its suitable configuration.
# wvdialconf
Now we will add these lines to /etc/kannel/kannel.conf
:
# USB MODEM DEFINITION group = modems id = myusbmodem init-string = "ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0" message-storage = "SM" need-sleep = true # SMSC USING USB MODEM group = smsc smsc = at smsc-id = smsc2 my-number = [SIM card] sms-center = [sms center number] device = /dev/ttyUSB1 speed = 9600 sim-buffering = true
Restart Kannel
When all the configurations are done, we need to restart Kannel:
# service kannel restart
Useful Kannel URLs
To send SMS:
http://kannel_server_ip_address:13002/cgi-bin/sendsms?username=username_for_sending_sms&password=password_for_sending_sms&smsc=smsc-id_to_use&to=phone_number_1 phone_number_2&text=message_content
To check Kannel status:
http://kannel_server_ip_address:13000/status?password=password_for_kannel_status
To open Kannel admin page:
http://kannel_server_ip_address:13000/status?password=password_for_kannel_admin
Integrating Kannel with Nagios
The Kannel server is ready and now we need to tell Nagios to use it for sms alert.
Create nagios commands for sms alert
Edit commands.cfg
# vi /usr/local/nagios/etc/objects/commands.cfg
And add this:
define command{ command_name notify-host-by-sms command_line /usr/bin/curl http://kannel_server_ip_address:13002/cgi-bin/sendsms?username=username_for_sending_sms&password=password_for_sending_sms&smsc=smsc-id_to_use&to=$CONTACTPAGER&text=$HOSTNAME$ is $HOSTSTATE$ } define command{ command_name notify-service-by-sms command_line /usr/bin/curl http://kannel_server_ip_address:13002/cgi-bin/sendsms?username=username_for_sending_sms&password=password_for_sending_sms&smsc=smsc-id_to_use&to=$CONTACTPAGER&text=$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ }
Note:
-
Please adapt the values in the URL except
$CONTACTPAGER
,$HOSTNAME$
,$HOSTSTATE$
,$HOSTALIAS$
,$SERVICEDESC$
and$SERVICESTATE$
- We have used
curl
, so if it’s not available on your system, you need to install it
# apt-get install curl
Add notification commands to contacts
Edit commands.cfg
# vi /usr/local/nagios/etc/objects/commands.cfg
And in the contact section, add this:
service_notification_commands notify-service-by-sms host_notification_commands notify-host-by-sms pager [phone_number]