Ad Widget


Zabbix 1.4.4 SMS not working

  • Filter
  • Time
  • Show
Clear All
new posts

    I gave up on zabbix SMS function and this is what i use.

    For linux. (iam using centos 5)

    How to send SMS from mobilephone that supports AT commands for SMS (all phons don't do it)

    This is how I do it.

    1. Install

    2. insert you USB cable from your phone (ex. Ericsson M600i )into your linux server runnin zabbix.

    3. cat /var/log/messages and check what the Phone interface will be.

    Feb 4 11:48:14 netscan kernel: usb 2-1: new full speed USB device using uhci_hcd and address 7
    Feb 4 11:48:14 netscan kernel: usb 2-1: configuration #1 chosen from 1 choice
    Feb 4 11:48:14 netscan kernel: cdc_acm 2-1:1.1: ttyACM0: USB ACM device
    Feb 4 11:48:14 netscan kernel: cdc_acm 2-1:1.3: ttyACM1: USB ACM device
    Feb 4 11:48:14 netscan kernel: cdc_acm 2-1:1.5: ttyACM2: USB ACM device

    4. now you know your phone is connected via ttyACMx (x=0-2, mine was 1 (depends on the USB port ya connect to. ))

    5. now time to send a SMS..

    gsmsendsms -d /dev/ttyACM1 -b 115200 +ccmmmmmm "fableman made my day"

    (cc=your county code .ex +46 for sweden) mm=your mobile phone (and remove the first 0 if any)


    gsmsendsms -d /dev/ttyACM1 -b 115200 +46701234567 "fableman made my day"

    (will send a sms to a swedish mobile phone at 070-1234567)

    To inplement into zabbix..

    1. EDIT /etc/zabbix/zabbix_server.conf


    2. put this example scriopt into etc/zabbix/externalscripts/


    /usr/bin/gsmsendsms -d /dev/ttyACM1 -b 115200 $1 "$2 $3 $4 $5 $6 $7 $8 $9"

    3. chmod zabbix:root /etc/zabbix/externalscripts/*
    chown u+x /etc/zabbix/externalscripts/*

    4. restart zabbix

    5. in zabbix create a new Media and select script
    send to yout mobile phone number

    Hope this small fast guide helped anyone.

    Maybee there is other ways but works for me

    Hint: The script I included should be modify to handle lots of inc SMS same time... a que system.. (Iam doing it my self at the moment) let me know if ya need it later.


      Here is the SMS que solution soo it can handle a lots and lots of sms same time without making the gsm modem to go crazy..

      Ya need to make 2 scripts

      This is the script to Call from zabbiz (Media - script function)

      name: EGEN-SMS
      #Håkan Franzen 2008

      tal=`echo $1 $2 $3 $4 $5 $6 $7 $8 $9`

      /etc/zabbix/externalscripts/EGEN-SMS-SEND $tal &
      #end of script 1

      Here is script number 2

      Name: EGEN-SMS-SEND
      #Hakan Franzen 2008

      while [ $tal666 = 1 ];do
      randomal=`echo $RANDOM | cut -c -2`
      tal=`ps x | grep -c gsmsendsms`
      if [ $tal = 1 ];then
      /usr/bin/gsmsendsms -d /dev/ttyACM1 -b 115200 $1 "$2 $3 $4 $5 $6 $7 $8 $9"
      ping -c$randomal >/dev/null

      This solution works really nice for me.


        Originally posted by fableman View Post
        This solution works really nice for me.
        Hi fableman,
        it seem works to send sms to single person only. am i right? I have one trigger which have send sms action into a group of IT team and only one member received sms.

        Any comment?



          I suggest you to...

          1. install smstools ( I use this for my centos5: smstools-3.0.10-1.el5.i386.rpm )

          2. this is my config file for it. ( Iam using SAMBA75 device to send SMSes)
          [[email protected] ~]# cat /etc/smsd.conf

          devices = GSM1
          logfile = /var/log/smsd.log
          loglevel = 7

          device = /dev/ttyACM0 #/dev/ttyS0
          #incoming = yes
          pin = 2991
          mode = new #old /new new = default

          init1 = AT+CPMS="MT","MT","MT"

          3. adduser sms to your server.

          4. Configure sendmail on server soo [email protected] can recive email. (login as user sms and check that he can recive mail using mail command)

          5. make a file at : /home/sms/mailgate-runner


          6. chmod u+x /home/sms/mailgate-runner

          7. Now we creat a simple but solid mailgate I made my self.

          (sorry foy the swedish comments in the script, I just made it for my self at start)

          If you want your sms to be FLASH (popup on mobile phone uncomment the flash yes in my script, some phones like ericson p990i go crazy afters ome flash sms, soo I have it turned off, else its a nice feature)

          My sms gate will send 2 sms if message over 160 chars.
          and it can recive email from outlook and lotus notes and decote minmi to plain text. (not needed for zabbix but still fun to mail from other clients)

          Create /home/sms/mailgate


          # Håkan Franzen 2008
          # mail gate som även klarar mail in med MIME codad text, från outlook express /lotus notes.
          # skickar max 160 x 2 tecken uppdelat i 2 bilagor... SMS som : flash Yes.

          filename=`date +%N`
          rm /home/sms/SMS-* >/dev/null 2>&1
          mail -f /var/spool/mail/sms </home/sms/MAIL-MACRO >/home/sms/MAILIN-DATA-$filname

          FINNSMAIL=`cat /home/sms/MAILIN-DATA-$filname | grep -c "0 messages"`
          if [ $FINNSMAIL = 1 ]
          #echo "no mail"
          rm /home/sms/MAILIN-DATA-$filname >/dev/null 2>&1
          exit #inga mail in så vi skiter i det..

          # KOLLA OM MIME

          cat /home/sms/MAILIN-DATA-$filname | { while read line
          subject=`echo "${line}" |cut -b -8`

          #plocka fram telnummret
          if [ "$subject" == "Subject:" ]
          tel=`echo "${line}" |cut -b 10-`

          if [ $mupp = 2 ]
          echo "${line}" >>/home/sms/SMS-PRE-$filename #extracta raderna från emailet till tempfilen


          if [ $mupp = 1 ]


          ####### Fixar bort var/log/sms skiten som läggs till från sendmail
          cat /home/sms/SMS-PRE-$filename | grep -v "/var/spool/mail/sms" >/home/sms/DELME_SMS-PRE-$filename
          cp -f /home/sms/DELME_SMS-PRE-$filename /home/sms/SMS-PRE-$filename
          rm /home/sms/DELME_SMS-PRE-$filename

          ####### FIXA TILL MIME OM DET BEHÖVS!

          ISITMIME=`cat /home/sms/SMS-PRE-$filename | grep -c "MIME format"`

          if [ $ISITMIME = 1 ]

          MIME=`cat /home/sms/SMS-PRE-$filename |grep -m1 -A25 "Content-Type: text/plain;" | awk '/plain;/,/-=/ { print }'| awk '/quoted-printable/,/-=/ { print }'| sed -e 's/Content-Transfer-Encoding: quoted-printable//g'|grep -v "=_NextPart"|sed -e 's/=C5/Å/g'|sed -e 's/=C4/Ä/g'|sed -e 's/=D6/Ö/g'|sed -e 's/=E5/å/g'|sed -e 's/=E4/ä/g'|sed -e 's/=F6/ö/g'|grep -v "=_alternative" `

          echo "$MIME" >/home/sms/SMS-PRE-$filename


          #lägg till check för 160 tecken max mm mm

          MAX160=`cat /home/sms/SMS-PRE-$filename | sed 's/At EOF//g'` #sedan plockat bort At EOF som lägger till från sendmail bash mailing.
          SMS1=`echo $MAX160 | cut -b 0-159`
          SMS2=`echo $MAX160 | cut -b 160-320`

          #echo "SMS1: $SMS1"

          if [ "$SMS2" = "" ]

          #----- kolla tel nummret plocka bara ut nuffrorna

          tel=`echo "$tel" | sed 's/[a-zA-Z+-]*//g'` # använder sed för att bara plocka ut nuffror i subjektet. tar bort alla z.aA-Z - +

          # !!!!!!!! ------------------> change "46" to your country code !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!
          telcheck=`echo "$tel" | cut -b -2| grep -c "46"` #kolla om telnummret börjar med 46 annars någe fel.

          SMS1=`echo "$SMS1" | sed 's/[><]*//g'` #bort med <>
          SMS2=`echo "$SMS2" | sed 's/[><]*//g'` #bort med <>

          #----- SKICKA SMS(es)

          if [ $telcheck = 1 ]

          then #skicka SMS

          echo "To: $tel" >/home/sms/SMS-$filename
          # echo "Flash: yes" >>/home/sms/SMS-$filename #Flash: yes

          echo "" >>/home/sms/SMS-$filename
          echo "$SMS1" >>/home/sms/SMS-$filename

          cp /home/sms/SMS-$filename /var/spool/sms/outgoing/ # lägger filen i kö för utskick.
          rm /home/sms/SMS-$filename

          if [ $entill = 1 ]

          ping -c 3 >/dev/null 2>&1 #3 sekunders pause sean sänd part2
          echo "To: $tel" >/home/sms/SMS-PART2-$filename
          # echo "Flash: yes" >>/home/sms/SMS-PART2-$filename
          echo "" >>/home/sms/SMS-PART2-$filename
          echo "$SMS2" >>/home/sms/SMS-PART2-$filename

          cp /home/sms/SMS-PART2-$filename /var/spool/sms/outgoing/ # lägger filen i kö för utskick.
          rm /home/sms/SMS-PART2-$filename

          rm /home/sms/SMS-PRE-$filename #städa upp temp jox


          echo "fel designat mail!!"
          #exit -65


          rm /home/sms/MAILIN-DATA-$filname >/dev/null 2>&1

          8. on the user sms make a crontab job:
          */1 * * * * /home/sms/mailgate-runner >/dev/null

          (will run script mailgate-runner every minute)


          make sure the user sms can create files in /var/spool/sms/outgoing/

          9. Now all ya have todo is from zabbix or any other alert programs send a mail to [email protected] with subject= your phone number

          10 . create a zabbix user called MAIL2SMS
          Using Media Email that point to [email protected]

          11. soo now you can add more users to your zabbix and under: "Configure Actions" In zabbix add your tech guys.

          Operation type: send message
          Send message to: Single user

          Subject= phone number ex: 46123123123 ( 46=sweden)

          Good luck...
          Last edited by fableman; 01-07-2008, 10:22.


            Thanks 4 ALL

            Hi Fableman,
            Thanks, it's very inspiring and give me more overview on how flexible ZABBIX is.
            I'm using FreeBSD 7.0-STABLE, i'll looking into it. Today i have made "big" progress on ZABBIX's sms feature *at least for my self*. SMS feature now working correctly after i do changes on my serial port configuration.

            my oriniginal serial ports configuration:
            fbsdzbx# stty -a -f /dev/cuad0
            speed 9600 baud; 0 rows; 0 columns;
            lflags: icanon isig iexten -echo -echoe -echok -echoke -echonl -echoctl
                    -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
            iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
                    brkint -inpck -ignpar -parmrk
            oflags: opost onlcr -ocrnl -oxtabs -onocr -onlret
            cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow
                    -dtrflow -mdmbuf
            cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
                    eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
                    lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
                    status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;
            changed to:
            fbsdzbx# stty -a -f /dev/cuad0
            speed 115200 baud; 0 rows; 0 columns;
            lflags: icanon isig iexten -echo -echoe -echok -echoke -echonl -echoctl
                    -echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
            iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel -ignbrk
                    brkint -inpck -ignpar -parmrk
            oflags: opost onlcr -ocrnl -oxtabs -onocr -onlret
            cflags: cread cs8 -parenb -parodd hupcl clocal -cstopb -crtscts -dsrflow
                    -dtrflow -mdmbuf
            cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>;
                    eol2 = <undef>; erase = ^?; erase2 = ^H; intr = ^C; kill = ^U;
                    lnext = ^V; min = 1; quit = ^\; reprint = ^R; start = ^Q;
                    status = ^T; stop = ^S; susp = ^Z; time = 0; werase = ^W;
            Hope this experience will inspiring others too who have difficulties on SMS feature as well



              I mostly made my own mail gateway to be able send sms alerts from zabbix and from other devices/php/bash scripts and soo on using email.
              Last edited by fableman; 14-05-2008, 09:13.


                I have the same error
                Last edited by Audrius; 28-06-2008, 17:38.


                  Originally posted by alexander View Post
                  i've had such error as you.
                  my solution is to modify in .../zabbix-1.4.4/src/libs/zbxsms/sms.c this line:
                  {"AT+CMEE=2\r" , "OK" , 5 },
                  {"AT+CMEE=2\r" , "ERROR" , 5 },
                  and recompile...
                  works great
                  I get an error in Actions: Expected [OK] received [AT+CMEE=2ERROR]

                  I tried to modify sms.c and recompile it. I restarted zabbix_server, but I get the same error.


                    Solved. I recompiled all zabbix, not only sms.c
                    Now everything works perfectly ;-)


                      I also got the "Expected [+CMGS: ] received [OK]"

                      I use a Siemens MC35i. Eventually I figured out the trick.

                      Step 1

                      Switch user to the "zabbix" user:

                      su - zabbix
                      Step 2

                      Use minicom to connect as follows:

                      minicom --baudrate 19200 --device /dev/ttyS0 --8bit
                      Step 3

                      Once inside minicom, put the GSM modem into the correct mode:

                      Step 4

                      Send a test message.

                      > attempt 1    {type Ctrl-Z here. Don't hit <ENTER> !! Touch nothing else}
                      It doesn't give you the desired +CMGS: response. So, try again.

                      Step 5

                      > attempt 2    {type Ctrl-Z here. Don't hit <ENTER> !! Touch nothing else}
                      +CMGS: 94
                      Now, strangely, it gives the correct response.

                      Step 6

                      Now, exit minicom without resetting the modem.
                      Do this with the Ctrl-A Q key sequence.

                      This will preserve the CMGF=1 state that you put the modem into.

                      Step 7

                      Now test it in Zabbix


                        Siemens MC35i HELP


                        I have the same problem as azabbixuser and similar to bee. I hope you guys can help me! I cannot get zabbix to send the sms. I am not an expert on Linux, and I am running Zabbix on Ubuntu 12.04.

                        Couple of facts:

                        - In Zabbix, e-mail alerts are sent ok, and I am using the same trigger for SMS, and I can see that Zabbix tries to send the sms.

                        - I am able to send sms using minicom from both my root user and my zabbix user, the permissions for the ttyS0 are set correctly.

                        - I get the following in Zabbix audit for the sms when the serial speed is set to 19200:
                        Expected [+CMGS: ] received [OK]

                        [email protected]:~$ stty < /dev/ttyS0
                        speed 19200 baud; line = 0;
                        min = 1; time = 5;
                        ignbrk -brkint -icrnl -imaxbel
                        -opost -onlcr
                        -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

                        - I get this message in the Zabbix audit:
                        Expected [OK] received [] When my ttyS0 port settings with speed 115200 are like this:

                        [email protected]:~$ stty < /dev/ttyS0
                        speed 115200 baud; line = 0;
                        min = 1; time = 5;
                        ignbrk -brkint -icrnl -imaxbel
                        -opost -onlcr
                        -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke

                        I would really appreciate your help as I have spent so much time trying to get this thing working



                          Just wanted to let you know, and in case this is helpful with someone with the same problem in the futture!

                          When getting this error message:
                          Expected [+CMGS: ] received [OK]

                          All I did was removed a chunk of characters from my "Alert" message and then it works. It seems like using Zabbix, the sms message cannot contain more than x amount of characters ( I am using approximately 100 characters and it works perfectly!)

                          Hope this is helpful for someone!


                            Thank you very much
                            This guide help me a lot.

                            I encounter that default some gsm modem set their baudrate to 9600.
                            When you send sms by 3rd software, it use 3rd software baudrate to send sms (in this case is 115200) and sms is sent

                            However zabbix use default baudrate as 9600. So it can not send sms. We have to change default baudrate in gsm modem from 9600 to 115200 and zabbix can send sms like a charm


                              Drooged is quite correct here. The clue is.... SMS (short message service) which is normally limited to 160 chars per SMS.

                              I'd been mucking about with this for ages eg permissions, baud rates etc and no luck.
                              Shortened the message down and boom.... it went. Thanks Drooged!


                                Now I just have to figure out why it sends 3 messages instead of 1 and reports that it hasn't been sent even though the text is on my phone!



                                No announcement yet.