MWI Notification

编程入门 行业动态 更新时间:2024-10-25 04:15:56

<a href=https://www.elefans.com/category/jswz/34/1689770.html style=MWI Notification"/>

MWI Notification

/?p=14

 

Since some people on the mailing lists are asking for this, I decided to release it into the public domain.

Asterisk MWI is an interesting animal. Most people don’t realize that the MWI light is turned on simply by the presence or absence of the msg.txt files in the voicemail user’s directory. Using the method I’m outlining here will allow you to keep the load light on any call servers and have the voicemail server(s) handle notification and voicemail storage. This method is also immediate, since every time a call is made, Asterisk does the processing and sending of the MWI instead of a cron job that’s run every X minutes.

The first thing you’ll need is the notify_vmail_extern.sh script:

#!/bin/bashCONTEXT=$1
EXTEN=$2
NUMVMS=$3SCMCMD="/usr/local/bin/notify_extern.sh $CONTEXT $EXTEN $NUMVMS"ssh ${SERVER} "$SCMCMD" > /dev/null 2>&1 &

This script goes on the voicemail box(es). Asterisk automatically sends the three arguments to the externnotify script, so don’t worry about those, just make sure your script has them. The SCMCMD is actually the script and controls that will be run on the other servers as well. The ssh command is what actually does the notification. You can have as many of these in here as necessary to send notifications out. If your phone is registered to only one server, you can probably do some creative lookups based on the arguments (either a db lookup for location information based on extension). If the phone can be registered anywhere, you can just put a series of ssh commands in to send the command to all the servers at once.

In order for that script to work, you must have ssh keys from the user Asterisk is running under on the voicemail box to the user that Asterisk is running under on the other machines. That is outside the scope of this article.

Next, you’ll need the script that runs on the call servers that will be doing the final notification:

#!/bin/bashCONTEXT=$1
EXTEN=$2
NUMVMS=$3NOCMD="rm -f /var/spool/asterisk/voicemail/$CONTEXT/$EXTEN/INBOX/*"
CREATECMD="mkdir -p /var/spool/asterisk/voicemail/$CONTEXT/$EXTEN/INBOX"if [[ $NUMVMS = "0" ]]; then$NOCMD
else$NOCMD$CREATECMDfor ((count = 1; count <= $NUMVMS; count++)); doif [ $count -lt 10 ] ; then msgcount=000$countelif [ $count -lt 100 ] ; then msgcount=00$countelif [ $count -lt 1000 ] ; then msgcount=0$countfiTOUCHCMD="touch /var/spool/asterisk/voicemail/$CONTEXT/$EXTEN/INBOX/msg$msgcount.txt"$TOUCHCMDdone
fi

This script is pretty straightforward. All it does is take the arguments sent, parse through the number of voicemails, and dependent on how many there are, either create that number of message files, or delete them outright. This process is about as immediate as the ssh comand can get.

Finally, on the voicemail server, edit the voicemail.conf file and configure the externnotify option like this:

externnotify=/usr/local/bin/notify_vmail_extern.sh

In Asterisk, do a reload app_voicemail.so and you’re done Watch and make sure that it’s working.

UPDATE: In response to comments below, Asterisk 1.4 switched to checking for specific lengths of the msgXXXX.txt file name, so the old script didn’t work anymore.  The update in blue above makes it work with later versions of 1.4.

更多推荐

MWI Notification

本文发布于:2024-02-12 23:14:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1689767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MWI   Notification

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!