把话单(acc) http post出去,如果用OpenSIPS来实现,那so easy
但在kamailio这边,需要好几个模块一起工作才行
oadmodule "acc.so"
loadmodule "mqueue.so"
loadmodule "rtimer.so"
loadmodule "acc_json.so"
loadmodule "http_client.so"
loadmodule "dialog.so"max_while_loops=100 # 全局参数modparam("acc", "cdr_enable", 1)
modparam("mqueue", "mqueue", "name=cdr_events;size=100000")modparam("acc_json", "cdr_enable", 1)
modparam("acc_json", "cdr_output_mqueue", "cdr_events")
modparam("acc_json", "cdr_extra","callid=$dlg(callid);""from=$dlg(from_uri);""to=$dlg(to_uri);""h_id=$dlg(h_id);""h_entry=$dlg(h_entry);""src_user=$fU;src_domain=$fd;src_ip=$si;""dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")modparam("dialog", "db_mode", 0)
modparam("dialog", "hash_size", 1024)
modparam("dialog", "enable_stats", 1)
modparam("dialog", "profiles_with_value", "caller")
modparam("dialog", "track_cseq_updates", 1)modparam("http_client", "keep_connections", 1)
modparam("http_client", "httpcon", "nsqd=>http://localhost:4151/pub?topic=acc")modparam("rtimer", "timer", "name=nsqt;interval=1;mode=1;")
modparam("rtimer", "exec", "timer=nsqt;route=RUN_CDR_PUBLISH")route[RUN_CDR_PUBLISH] {
...
}
acc模块是cdr引擎
acc_json模块把产生的cdr加到mqueue的队列
路由脚本在定时器路由里面从队列里面取出cdr,通过http_client发送出去
还需要加载dialog模块,可参考acc_json模块的参数(cdr_enable)说明
下面这段日志可供参考
{# start_time,end_time,duration是自动的,不用配置"start_time": "1688630139.405","end_time": "1688630143.947","duration": "4.542",# 下面的参数对应acc_json模块的cdr_extra参数"callid": "NGI4YTM4YjQ1YmQ2NzY0NTRiM2U0NWZhYjE0NDA3Yzg.","from": "sip:1000@192.168.1.123","to": "sip:1001@192.168.1.123","h_id": "781","h_entry": "918","src_user": "1000","src_domain": "192.168.1.123","src_ip": "10.0.6.1","dst_ouser": "1001","dst_user": "1001","dst_domain": "10.0.6.1"
}