Ad Widget

Collapse

SMS sent empty

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Z4Gai
    Junior Member
    • Dec 2005
    • 2

    #1

    SMS sent empty

    I'm using Zabbix 1.0 and have configured Zabbix to use the following script bellow through a pre sudo script that calls it (do to permissions).
    The problem is that the script doesn't get the parameters (Send to, Subject and Body) from Zabbix, the $1 $2 $3 remains empty, I have tested it with manually entering the number and the SMS is sent but shows only Zabbix: -
    Meaning that it does not get the parameters from Zabbix.

    What am I doing wrong?

    Any help will be appreciated

    I'm using this script:


    #!/bin/sh

    PATH=/bin:/sbin:/usr/bin:/usr/sbin
    LOGFILE="/var/log/zabbix/sendsms.log"

    echo "Recipient='$1' Subject='$2' Message='$3'" >> ${LOGFILE}

    MOBILE_NUMBER=`echo "$1" | sed s#\s##`

    # Log it
    echo "echo 'Zabbix: $2 - $3' | /usr/bin/gnokii --sendsms '${MOBILE_NUMBER}'" >>${LOGFILE}

    # Send it
    echo "Zabbix: $2 - $3" | /usr/bin/gnokii --sendsms "${MOBILE_NUMBER}" 1>>${LOGFILE} 2>&1

    # EOF
  • morgolis
    Member
    • Oct 2004
    • 33

    #2
    There is an easier way, just set up a user that has the email address you're trying to send to.

    EG:
    User - Mobile Phone
    Email address - [email protected]

    Then set either add the user to a specific group and have the trigger email that group OR just have the trigger send to that specific user.

    Comment

    • Avatar
      Junior Member
      • Jun 2005
      • 19

      #3
      I'm using daemon and scripts for zabbix

      #!/bin/bash
      #
      # Daemon for send sms
      #

      spool_folder=/var/spool/sms/outgoing
      # Pid file
      script_pid="/var/spool/sms/${0##*/}.pid"
      # Log file
      script_log="/var/log/sms/${0##*/}.log"


      if ! which gnokii >/dev/null; then
      echo "No program: gnokii" >&2
      exit 1
      fi

      if [ ! -d "${spool_folder}" ]; then
      echo "Error folder spool folder: ${spool_folder}" >&2
      exit 1
      fi

      # pid file
      if [ -f "${script_pid}" ]; then
      if ps `cat ${script_pid}` >/dev/null; then
      echo "Error: process already running" >&2
      exit 1
      fi
      fi

      (
      echo $! >${script_pid}
      trap "rm -f ${script_pid}; exit" 0 1 2 3 15

      while : ; do
      files=$(ls ${spool_folder} 2>&1)
      if [ $? -eq 0 ]; then
      for ifile in ${files}; do
      ffile="${spool_folder}/${ifile}"
      cfile=$(cat ${ffile})
      number=$(echo "${cfile}" |head -1 |grep "[0-9]\{7\}")
      if [ $? -ne 0 ]; then
      echo "$(date "+%Y-%m-%d %H:%M:%S") Error number phone in message
      : "${cfile}
      rm -f ${ffile}
      continue
      fi
      content=$(echo "${cfile}" |grep -v ${number})
      if [ $? -ne 0 ]; then
      echo "$(date "+%Y-%m-%d %H:%M:%S") Error content in message: "${
      cfile}
      rm -f ${ffile}
      continue
      fi
      echo -n "$(date "+%Y-%m-%d %H:%M:%S") Send sms "${cfile}": "
      echo "${content}" |gnokii --sendsms ${number} >/dev/null 2>&1
      if [ $? -eq 0 ]; then
      echo "ok"
      rm -f ${ffile}
      else
      echo "false"
      fi
      done
      fi
      sleep 10
      done
      ) >>${script_log} 2>&1 &


      #!/bin/sh
      #
      # Zabbix sms
      #
      if [ ! "$1" ]; then
      exit 1
      fi

      cat >/var/spool/sms/outgoing/zabbix-$$ <<EOF
      $1
      $2
      $(date "+%Y.%m.%d %H:%M:%S")
      EOF

      Comment

      Working...