Ad Widget

Collapse

Zabbix 2.0.5 and Alertscripts

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • monstermania
    Junior Member
    • Apr 2013
    • 8

    #1

    Zabbix 2.0.5 and Alertscripts

    Hello Again,
    i try to send zabbix-alerts by sms.
    I've installed a WebStick into my zabbix system. i can send sms by using gammu from shell.

    I've placed a script 'smsgammu.sh' into /usr/local/share/zabbix/alertscripts

    Code:
    #!/bin/sh
    HOME=/etc
    PATH=/bin:/sbin:/usr/bin:/usr/sbin
    LOGFILE="/var/log/zabbix/zabbix-sms.log"
    echo "Recipient='$1' Message='$3'" >> ${LOGFILE}
    MOBILE_NUMBER=`echo "$1" | sed s#\s##`
    # Log it
    echo "echo $3 | /usr/bin/sudo /usr/bin/gammu --sendsms TEXT ${MOBILE_NUMBER}" >>${LOGFILE}
    # Send it
    echo "$3" | /usr/bin/sudo /usr/bin/gammu --sendsms TEXT "${MOBILE_NUMBER}" 1>>${LOGFILE} 2>&1
    # EOF
    Then i made the script executable. After that test the Script with the user 'zabbix'.
    From Shell everything works fine. The sms was sent to me an the log entry was written.
    Then i configured the 'smsgammu.sh'-Script an new media type in zabbix administration.
    But no sms where sent out of zabbix! And no log entry was made.

    Where is the problem?
    I've seen that many users have problems mit alertscripts. Is there any log for the alertscripts actions?

    best regards
    Dirk
  • monstermania
    Junior Member
    • Apr 2013
    • 8

    #2
    Hello again,
    now it works.
    I can send sms-alerts from zabbix using my Webstick.

    I've changed the owner/group of the alertscripts-folder to 'zabbix'. Then I've changed the permission to 777.

    Then i SU to 'zabbix' and test the send of sms from shell using gammu. I get a message that the device is not present.
    I made an new configuration for gammu (gammu-config) under the zabbix user account (/dev/ttyUSB2). After that i can send sms with the zabbix user from shell.

    Then i test my sms action out of zabbix but i get the following error into the log: 'Sorry, user zabbix is not allowed to execute '/usr/bin/gammu --sendsms TEXT +49xxxxxxxxx' as root on zabbixsrv.'
    So i modified the 'smsgammu.sh'
    Code:
    #!/bin/sh
    HOME=/etc
    PATH=/bin:/sbin:/usr/bin:/usr/sbin
    LOGFILE="/var/log/zabbix/zabbix-sms.log"
    echo "Recipient='$1' Message='$3'" >> ${LOGFILE}
    MOBILE_NUMBER=`echo "$1" | sed s#\s##`
    # Log it
    echo "echo $3 | /usr/bin/gammu --sendsms TEXT ${MOBILE_NUMBER}" >>${LOGFILE}
    # Send it
    echo "$3" | /usr/bin/gammu --sendsms TEXT "${MOBILE_NUMBER}" 1>>${LOGFILE} 2>&1
    # EOF
    After that it works!

    Comment

    Working...