Asterisk call files

Asterisk 中有一个类似于 Linux 中的 crontab 那就是 call filesVoip Info 中这样介绍

Asterisk 中 call files 是个结构化文件,当移动到适当的目录时,可以自动发出呼叫。
call files 是自动拨打电话的好方法,无需使用更复杂的 Asterisk 功能,
如 AGI,AMI 和拨号方案,并且只需要很少的技术知识即可使用。

想要使用 call file,首先得了解其语法

Channel: 用于呼叫的通道

CallerID: 形如 “Some Name” <1234>

MaxRetries: 失败前的重试次数,不包括初始尝试次数。默认值 0,如果失败则不重试.

RetryTime: 重试前等待多少秒。默认值为300(5分钟).

WaitTime: 振铃时长。默认为45秒.

Account: 通话的帐户代码。此值将分配给CDR(帐户代码). 当呼叫应答时,调用如下: Context: extensions.conf 里的上下文 Extension: extensions.conf 扩展 Priority: 指定扩展的优先级; (数字或标签) Set: 也可以为通道可用的变量赋值,就好像您在拨号方案中执行了Set(var = value)一样。可以指定多个Setvar: Application: 要执行的应用程序 (use instead of specifiying context, extension and priority) Data: 应用程序需要的参数 Archive: Yes/No – 如果“否”,则删除呼叫文件。如果设置为“yes”,则将调用文件移动到Asterisk假脱机目录的“outgoing_done”子目录。默认是删除调用文件. 如果存档调用文件,Asterisk将附加到调用文件 StartRetry: <pid> <retrycount> (<time>) [<Asterisk 进程> <重试次数> (<执行时间>)] Status: 值为 "Expired", "Completed" or "Failed"

举个栗子,在 /var/tmp 目录新建个 hello-world.call

Channel: SIP/8001
Application: Playback
Data: hello-world
Archive:yes

放入 /var/spool/asterisk/outgoing/ (在 /etc/asterisk/asterisk.conf 指定)中,如果想要这个文件执行,还有个前提,那就是 Asterisk 中加载了 pbx_spool.so

cp /var/tmp/hello-world.call /var/spool/asterisk/outgoing/

紧接着你发现 8001 分机想起铃声,接起来,听到的便是 hello-world 语音,然后关机。这是你发现原来目录里的此文件不见了,但是在 /var/spool/asterisk/outgoing_done/ 发现了此文件,但是文末多了两行

StartRetry: 17379 1 (1534577565)
Status: Completed

这个示例是,把 hello-world.call 放入指定目录便执行了,那么我想延迟执行或是指定时间执行呢,答案便是改变文件的修改时间

stat hello-world.call
  File: `hello-world.call'
  Size: 86          Blocks: 8          IO Block: 4096   regular file
Device: fc03h/64515d    Inode: 44437235    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2018-08-18 15:43:07.170498715 +0800
Modify: 2018-08-18 15:45:00.000000000 +0800    <修改时间>
Change: 2018-08-18 15:42:57.697497136 +0800

这里简单解释下 AccessModifyChange

Access:访问时间,如使用 cat、less 查看了文件,此时间便会更新
Modify:修改时间,如使用 vim 改变了文件的内容,此时间便会更新
Change:改变时间,如使用 chmod 改变了文件了属性,此时间便会更新

那么只需要改变文件的修改时间,就可以让其在指定的时间执行

touch -m -d "2018-08-18 16:03:00" hello-world.call
mv hello-world.call /var/spool/asterisk/outgoing/hello-world.call

那么 hello-world.call 便会在 2018-08-18 16:03:00 执行。

猜你喜欢

转载自blog.csdn.net/molaifeng/article/details/81810070