Asterisk传出CDRlogging到Mysql

尝试使用自定义字段来使用cdr日志logging(到MySQL)。 我面对的问题是只有当一个呼出电话被放置,在呼入自定义字段我能够login没有问题。

我遇到问题的原因是因为我需要的自定义cdr字段是系统上每个用户的唯一值。

sip.conf

... ... [sales_department](!) type=friend host=dynamic context=SalesAgents disallow=all allow=ulaw allow=alaw qualify=yes qualifyfreq=30 ;; company sales agents: [11](sales_agent) secret=xxxxxx callerid="<...>" [12](sales_agent) secret=xxxxxx callerid="<...>" [13](sales_agent) secret=xxxxxx callerid="<...>" [14](sales_agent) secret=xxxxxx callerid="<...>" 

extensions.conf文件

  [SalesAgents] include => Services ; Outbound calls exten=>_1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@myprovider) ; Inbound calls exten=>100,1,NoOp() same => n,Set(CDR(agent_id)=11) same => n,CELGenUserEvent(Custom Event) same => n,Dial(${11_1},25) same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail) same => n(unavail),VoiceMail(11@asterisk) same => n,Hangup() same => n(busy),VoiceMail(11@asterisk) same => n,Hangup() exten=>101,1,NoOp() same => n,Set(CDR(agent_id)=12) same => n,CELGenUserEvent(Custom Event) same => n,Dial(${12_1},25) same => n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail) same => n(unavail),VoiceMail(12@asterisk) same => n,Hangup() same => n(busy),VoiceMail(12@asterisk) same => n,Hangup() ... ... 

对于上述示例中拨号scheme的入站部分,我可以插入自定义cdr字段(agent_id)。 但是在它上面,你可以看到拨号scheme的Oubound部分,我一直难以理解如何能够告诉拨号scheme哪个agent_id正在进行呼出呼叫。

我的问题:如何采取agent_id = [11]&agent_id = [12]和agent_id = [13]和agent_id = [14]等,并将其作为cdr的外地电话的自定义字段?

@ miken32的build议是一个好的。

另一种方法是让每个代理的SIP对等定义在一个通道variables中定义它们的代理ID:

 ; sip.conf [agent_12] type=peer setvar=__AGENT_ID=agent_12 

任何时候为这个对等体创build一个通道,都会自动设置AGENT_IDvariables。 因为我们以inheritance为前缀variables,所以从它创build的任何子通道(也就是通道)都将获得设置的AGENT_ID。

在您的出站拨号中,您可以在频道拨号上设置它,如下所示:

  ; Outbound calls exten =>_1NXXNXXXXXX,1,NoOp() same => n,Set(CDR(agent_id)=${AGENT_ID} same => n,Dial(SIP/${EXTEN}@myprovider) 

这将在CDR中设置agent_id列。

请注意,如果您需要设置拨号中创build的出站通道上的值,则可以使用预拨号处理程序 。

如果您不使用SIP对等方定义中的accountcode字段,则可以将其设置为代理ID,然后在出站拨号scheme中使用Set(CDR(agent_id)=CDR(accountcode))