You are on page 1of 1

Why GitHub?

Team Enterprise Explore Marketplace Pricing Search Sign in Sign up

z-afshar / zabbix-gammu-smsd Watch 1 Star 0 Fork 1

Code Issues Pull requests Actions Projects Wiki Security Insights

zabbix gammu smsd Installation Guide


Zahra Afshar edited this page on 14 Jan 2017 · 2 revisions

zabbix-gammu-smsd Pages 1

Find a Page…
send sms from zabbix server to phone number in case of events.
zabbix gammu smsd
receive sms from phone number and execute appropriate script based on sms text. Installation Guide

All message sending & receiving is performed by gammu-smsd.


Clone this wiki locally

Steps
https://github.com/z-af

##1- Install GSM Modem: You need a GSM modem with working SIM card connected to zabbix server. I personally use
Wavecom that connects through USB port

// is your OS detects your modem?


#dmesg | grep ttyUSB
usb 1-2: pl2303 converter now attached to ttyUSB0
// so my GSM modem is connected to /dev/ttyUSB0
// you can connect to it with tools like minicom and issue some AT command

##2- Install gammu & gammu-smsd Install gammu & gammu-smsd from repo or from source. I personally instelled latest
version (1.38.0) from source code with following commands:

#cd ~
#mkdir src
#cd src
#sudo yum group install 'Development Tools'
#wget https://cmake.org/files/v3.7/cmake-3.7.1.tar.gz
#tar zxvf cmake-3.7.1.tar.gz
#cd cmake-3.7.1
#./bootstrap --prefix=/usr
#gmake
#sudo gmake install
#export CMAKE_ROOT=/usr/share/cmake-3.7
#cd ..
#wget https://dl.cihar.com/gammu/releases/gammu-1.38.0.tar.gz
#tar zxvf gammu-1.38.0.tar.gz
#cd gammu-1.38.0
#./configure --prefix=/usr
#make
#sudo make install

##3- configure gammu configure gammu and make sure gammu detects your GSM Modem

#gammu-config
// generated by gammu-config
#cat ~/.gammurc
[gammu]
port = /dev/ttyUSB0
model =
connection = at115200
synchronizetime = yes
logfile =
logformat = nothing
use_locking =
gammuloc =

//send test message with gammu:


#echo "hello" | gammu --sendsms TEXT "+98XXXXXXXXXXX"

##4- Prepare database for using in gammu-smsd

// install mysql server


#wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
#yum localinstall mysql57-community-release-el7-7.noarch.rpm
#yum repolist enabled | grep "mysql.*-community.*"
#yum install mysql-community-server
#systemctl enable mysqld.service
#systemctl start mysqld.service
// determine mysql root temporary password
#grep 'temporary password' /var/log/mysqld.log
#mysql_secure_installation
//login to mysql
#mysql -uroot -p
mysql> create database smsdb;
mysql> grant all privileges on smsdb.* to 'smsd'@'localhost' identified by 'passw0rd';
mysql> flush privileges;
mysql> quit;

// import gammu-smsd mysql schema to database


#cd ~/src/gammu-1.38.0/docs/sql
// replace date string in mysql.sql file to avoid mysql error
#sed -ie 's/0000-00-00/1980-01-01/g' mysql.sql
#mysql -u smsd -p smsdb < mysql.sql

##5- config gammu-smsd : (see "man gammu-smsdrc" for details)

// edit configuration file


#nano /etc/gammu-smsdrc
[gammu]
port = /dev/ttyUSB0
connection = at115200

[smsd]
service = sql
driver = native_mysql
host = localhost
user = smsd
password = passw0rd
database = smsdb
debuglevel = 1
LogFile = /var/log/gammu/smsd.log
RunOnReceive = /opt/gammu/sms-parser.sh
InboxFormat = unicode
OutboxFormat = unicode
TransmitFormat = auto

// create log & script directories


#mkdir -p /var/log/gammu
#mkdir -p /opt/gammu

// restart gammu-smsd service


#systemctl restart gammu-smsd

// chack log file for ensure everything is working


#tail -fn10 /var/log/gammu/smsd.log
// you should see something like this:
Sat 2017/01/14 13:35:33 gammu-smsd[19930]: mode: Send=1, Receive=1
Sat 2017/01/14 13:35:33 gammu-smsd[19930]: deliveryreport = no
Sat 2017/01/14 13:35:33 gammu-smsd[19930]: phoneid =
Sat 2017/01/14 13:35:33 gammu-smsd[19931]: Connected to Database: smsdb on localhost
Sat 2017/01/14 13:35:33 gammu-smsd[19931]: Database structures version: 16, SMSD current version: 16
Sat 2017/01/14 13:35:33 gammu-smsd[19931]: Connected to Database native_mysql: smsdb on localhost
Sat 2017/01/14 13:35:33 gammu-smsd[19931]: Created POSIX RW shared memory at 0x7f400cfdd000
Sat 2017/01/14 13:35:33 gammu-smsd[19931]: Starting phone communication...
Sat 2017/01/14 13:35:38 gammu-smsd[19931]: Inserting phone info
Sat 2017/01/14 13:35:39 gammu-smsd[19931]: Read 0 messages

// send test message with gammu-smsd-inject ( see "man gammu-smsd-inject" )


#gammu-smsd-inject TEXT +98XXXXXXXXXX -text "message"

##6- configure zabbix for sending sms

// copy zabbix alert script to corresponding path


#chmod +x sendsms.sh
#cp sendsms.sh /usr/lib/zabbix/alertscripts
// test script from command line!
#/usr/lib/zabbix/alertscripts +98XXXXXXXXXXX hello-from-zabbix-server
// zabbix user can not send sms without permission, so give this permission to zabbix user
#visudo
// add following line to /etc/sudoers so zabbix user can send sms
zabbix ALL=NOPASSWD:/usr/bin/gammu-smsd-inject

create script media type in your zabbix server administration page

add sendsms media to corresponding user

create action (Event Source : Triggers)

send sms to zabbix administrators in case of problem

##7 - execute scripts based on received sms command in this section we configure gammu-smsd to execute sms command
parser and execute script based on sms command. note that this parser is very trivial and provide some basic functionality. you
can change the parser and command scripts for more advanced actions.

cd /opt/gammu
cp sms-parser.sh a.sh pong.sh backup-fw.exp .
chmod +x *.*
// make sure the following line in /etc/gammu-smsdrc on step 5
RunOnReceive = /opt/gammu/sms-parser.sh

##8- final word that's it! have fun with sms!

© 2020 GitHub, Inc. Terms Privacy Security Status Help Contact GitHub Pricing API Training Blog About

You might also like