Board logo

標題: QNAP Asterisk SIP IP Tracking [打印本頁]

作者: 角色    時間: 2010-9-8 22:04     標題: QNAP Asterisk SIP IP Tracking

trunk_ip_check.sh
  1. #!/bin/sh
  2. PEER="sz-gw"
  3. ASTCMD="/opt/sbin/asterisk -rx"
  4. NSLCMD="ping -c 1"

  5. OLD_IP=`$ASTCMD "sip show peer $PEER" | grep "Addr->IP" | cut -c 16- | cut -f2 -d\ `

  6. PEER_HOST=`$ASTCMD "sip show peer $PEER" | grep "ToHost" | cut -c 16- | cut -f2 -d\ `

  7. NEW_IP=`$NSLCMD $PEER_HOST | head -1 | cut -f3 -d\ | sed s/:// | sed s/\(// | sed s/\)//`

  8. if [ $NEW_IP != $OLD_IP ]
  9.       then
  10.         $ASTCMD "sip reload"
  11.         echo "$PEER `date` IP changed from $OLD_IP to $NEW_IP then sip reload" >> /opt/etc/asterisk/trunk_ip_change.dat
  12. fi
複製代碼
In the file /mnt/HDA_ROOT/.config/crontab add the following cron job
  1. */5 * * * * /bin/sh /opt/etc/asterisk/trunk_ip_check.sh
複製代碼
Restart the cron routine
  1. /etc/init.d/crond.sh restart
複製代碼
YH




歡迎光臨 電訊茶室 (http://telecom-cafe.com/forum/) Powered by Discuz! 7.2