`
jiagou
  • 浏览: 2589104 次
文章分类
社区版块
存档分类
最新评论

MWI Notification

 
阅读更多

http://asterisk.mdaniel.net/?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/bash

CONTEXT=$1
EXTEN=$2
NUMVMS=$3

SCMCMD="/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/bash

CONTEXT=$1
EXTEN=$2
NUMVMS=$3

NOCMD="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
        $CREATECMD
        for ((count = 1; count <= $NUMVMS; count++)); do
                if [ $count -lt 10 ] ; then msgcount=000$count
                elif [ $count -lt 100 ] ; then msgcount=00$count
                elif [ $count -lt 1000 ] ; then msgcount=0$count
                fi
                TOUCHCMD="touch /var/spool/asterisk/voicemail/$CONTEXT/$EXTEN/INBOX/msg$msgcount.txt"
                $TOUCHCMD
        done
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.

分享到:
评论

相关推荐

    Rogers(罗杰斯) MWI计算工具2018版

    Rogers(罗杰斯) MWI计算工具2018版 国际知名PCB厂商ROGERS为方便工程师更好的使用高频PCB板材,特推出专门用于微波阻抗计算的工具:微波阻抗计算器(Microwave Impedance Calculator)。一般来说,线路板材料的...

    15831 MWI FieldTestCasesv11.doc

    【文档标题】15831 MWI Field Test Cases v11.doc 提供的是一个关于AT&T公司的设备测试文档,特别关注Message Waiting Indicator(MWI)的现场测试案例。文档包含AT&T的商业秘密和专有信息,使用或披露其中的信息需...

    3D MWI_TheBreast_microwaveimaging_

    《3D MWI_TheBreast_microwaveimaging_》这一主题主要涉及的是3D微波成像技术在乳腺检测中的应用。微波成像(Microwave Imaging, MWI)是一种非侵入性的无损检测技术,它利用微波频率的电磁波穿透物体,并通过分析...

    使用mwi读取设备信息

    在这个场景下,"mwi"(可能指的是Management Wizard Interface或者某种自定义的工具)是用来借助WMI读取设备信息的方法。本文将深入探讨如何使用WMI来获取USB设备的信息。 WMI是微软对Web-Based Enterprise ...

    x-lite 软电话 4.5 版本支持MWI

    x-lite 软电话 4.5 版本支持MWI

    m_mwi2ox.zip_radar

    在给定的压缩包文件“m_mwi2ox.zip_radar”中,包含了一个名为“m_mwi2ox.m”的MATLAB程序,该程序设计用于实现雷达目标的航迹跟踪。以下是关于这个程序和相关技术的详细解释。 1. **MATLAB编程**:MATLAB是一种...

    MWI:此处包含所有为髓磷脂水成像编写的代码

    髓磷脂水成像(Myelin Water Imaging, MWI)是一种高级医学成像技术,用于研究和诊断神经系统疾病,特别是与髓磷脂相关的问题。髓磷脂是神经元外包裹的一层脂肪物质,对于神经信号的快速传导至关重要。MWI通过对特定...

    14677 AT&T MWI Test Specification v45.xls

    14677 AT&T MWI Test Specification v45.xls

    18104 AT&T MWI LTE Test Specification v15.xlsx

    18104 AT&T MWI LTE Test Specification v15.xlsx

    18104 AT&T MWI LTE Test Specification v14.xlsx

    18104 AT&T MWI LTE Test Specification v14.xlsx

    MWI-07-2011-B 插头端缠胶布.pdf

    操作指引文件MWI-07-2011-B详细阐述了在汽车行业中,特别是针对HV系列FG产品(包括HV1R*1***FGL****H*/HV7R*1***FGL****H*/HV9R*1***FGL****H*/HVS*等)进行插头端缠胶布的操作过程。这一过程对于保证汽车电子部件的...

    MWI-07-0812-C(灌胶).pdf

    【标题】: "MWI-07-0812-C(灌胶).pdf" 操作指引 【描述】: 本操作指引详细阐述了在HV系列FG产品中进行灌胶工艺的过程,包括使用C语言描述的操作步骤和注意事项,旨在确保产品质量和生产安全。 【标签】: "C语言 ...

    MPT MWI BLiF度量的演示MATLAB代码.zip

    1.版本:matlab2014/2019a/2021a,内含运行结果,不会运行可私信 2.附赠案例数据可直接运行matlab程序。 3.代码特点:参数化编程、参数可方便更改、代码编程思路清晰、注释明细。 4.适用对象:计算机,电子信息工程...

    MWI spinal cord atlases:使用髓鞘水成像的脊髓标准图谱-开源

    髓鞘水成像应用于 20 根健康脊髓,以创建 T2 度量健康人口图谱,描绘髓鞘水分数 (MWF) 的平均值和变化,以及几何平均 T2 (IEGMT2) 描述的细胞内和细胞外水流动性。 创建的地图集展示了与众所周知的解剖特征一致的...

    3MWi3升级款在北京、上海等四城市陕批新能源车牌照.pdf

    新能源汽车行业在近年来持续发展,其中BMW i3升级款车型在多个城市的成功获批新能源车牌照,标志着这一领域的重大进展。BMW i3升级款(非增程型)已在北京、上海、杭州和深圳获得许可,车辆可享受免费新能源车牌政策...

    MWI马拉维社会经济发展指标数据1960-2022GDP人口就业教科文财政收支贸易碳排放等.xlsx

    (指标翻译成了中文,还有指标中英文说明等相关的对照表页签,方便使用) 数据来源:WB世界银行世界发展指标WDI 数据范围:1960-2022 数据指标:每个地区1486个指标,涵盖社会经济发展各行各业的方方面面: ...

    matlab+ann源码-ANN-MWI:用于训练和测试髓鞘水成像网络(ANN-MWI)(.py)和数据预处理(.m)的源代码

    matlab+ann源码髓鞘水成像的人工神经网络:ANN-MWI 用于训练和测试网络的源代码 (.py) 以及提交给 Magnetic Resonance in Medicine 的手稿“用于髓鞘水成像的人工神经网络”中的数据预处理 (.m)。 概述 手稿中提出了...

    梯度幅值图像matlab代码-MWI:基于三分量拟合的髓磷脂水成像

    梯度幅值图像矩阵代码MWI 髓磷脂水成像 complex_three_comp_analysis.m 描述: complex_three_comp_analysis.m与幅值和相位多梯度回波图像和组织遮罩一起使用(以限制处理时间)以基于3分量复杂拟合和3分量幅度拟合...

    mwi-benchmark:新员工基准测试

    基准测试我们很高兴您有兴趣将您的名字戴在Midwestern Interactive的实习或入门级职位上。 请仔细阅读说明,并遵循基准测试过程中的步骤。指示请尽力完成以下步骤。 如果没有帐户,则所有应用程序都应存放在github...

Global site tag (gtag.js) - Google Analytics