Ad Widget

Collapse

Zabbix SMS Gammu Script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JasperB
    Junior Member
    • May 2009
    • 11

    #1

    Zabbix SMS Gammu Script

    My phone doesn't seem to work with zabbix, so I decided to use a more stable and working program (gammu).

    I've been able to script this program to work with a bash file (see this code

    Code:
    #!/bin/bash
    
    echo $1 $2 $3 $4 | /usr/bin/sudo /usr/bin/gammu --sendsms TEXT 06123456789
    I've added the sudo part to be able to run this as root with no password set for /usr/bin/gammu

    I've added this script to the external script dir and zabbix runs the script just fine when a trigger is needed.

    The only issue is that the program is missing it's configuration file (this says which phone/connection etc)

    When running this script it uses the .gammurc configuration file which is located in the root of my root user (type cd)

    I've tried copying this file and chowning/chmoding it properly, but still it's not reading/finding this file. Probably because the zabbix user account cannot be used to login and thus it has no root dir to place this config file in?

    Anybody using Gammu as a external script and know how to get around this?
  • pesadilla
    Member
    • Nov 2006
    • 69

    #2
    use option --config



    OPTIONS

    Parameters before command configure gammu behaviour:
    -c / --config <filename> ... name of configuration file

    Comment

    • JasperB
      Junior Member
      • May 2009
      • 11

      #3
      Thanks but that doens't work

      still seeing this in the server log :

      Code:
      Warning: Configuration could not be parsed!
      Warning: No configuration read, using builtin defaults!
      Error during reading device.
      That means it's not able to find or read the config file?
      Last edited by JasperB; 15-05-2009, 17:47.

      Comment

      • JasperB
        Junior Member
        • May 2009
        • 11

        #4
        *boot*

        Anybody know how I would be able to run this file as a root user in shell?

        In otherwords, I'm able to run this bash script from shell (./sms) and it works perfectly, but when zabbix runs this file it doesn't work.

        It runs the file ok (checked logs) but it says it's missing gammu's config file and this is obviously because it's being run as another user.

        To fix this issue I figured I would use sudoers (debian) and run it as root.

        I figured sudoers would be used like RUNAS in windows, but it seems this doesn't work properly. It doesn't seem to run it as root, because root has it's config files for gammu set-up.

        This is my bash script (which works when manualy running it)

        Code:
         
        echo $1 $2 $3 $4 | /usr/bin/sudo /usr/bin/gammu  --sendsms TEXT 06123456
        This is my sudoers file :

        Code:
        root    ALL=(ALL) ALL
        
        # Uncomment to allow members of group sudo to not need a password
        # (Note that later entries override this, so you might need to move
        # it further down)
        # %sudo ALL=NOPASSWD: ALL
        
        zabbix ALL=NOPASSWD: /usr/bin/gammu
        Anybody know what I'm doing wrong? Maybe because the zabbix user has no shell login ability?

        Comment

        • JasperB
          Junior Member
          • May 2009
          • 11

          #5
          Richv from the irc channel helped me

          added : export HOME=/root and it solved the problem

          Comment

          • dkp
            Junior Member
            • Aug 2010
            • 1

            #6
            Queuing SMS's

            I found that if you are sending a lot of sms's gammu flakes out unless you stagger them one at a time:

            Check out:
            http://my-mumbles.blogspot.com/2010/08/zabbix-sms-queuing.html

            Comment

            Working...