Select Sidearea

Populate the sidearea with useful widgets. It’s simple to add images, categories, latest post, social media icon links, tag clouds, and more.

Use Asterisk CDR details with call recorded from Cisco Call Manager

Use Asterisk CDR details with call recorded from Cisco Call Manager

Based on these how to: https://supportforums.cisco.com/discussion/12400836/cucm-call-recording-asterisk and https://www.ucguru.com/recording-call-manager-calls-asterisk/ and https://www.backloop.biz/en/products/call-recording-on-cisco-call-manager

We’ve created a script to use the native CDR details GUI to download and listen the audio file of recorded calls. We suggest to execute it using crontab every 10 minutes.

#!/usr/bin/php
<?php

$conf = parse_ini_file(“/etc/amportal.conf”);

//print_r($conf);

mysql_connect($conf[‘AMPDBHOST’],$conf[‘AMPDBUSER’],$conf[‘AMPDBPASS’]) or die(mysql_error());
mysql_select_db(“asteriskcdrdb”) or die(mysql_error());

$sql_cdr = “SELECT * FROM cdr WHERE dst = ‘1111200’”;
$ris_cdr = mysql_query($sql_cdr) or die($sql_cdr.” => “.mysql_error());
while ($data_cdr = mysql_fetch_array($ris_cdr)){
$tmp2 = explode(” “,$data_cdr[‘calldate’]);
$tmp_date = explode(“-“,$tmp2[‘0’]);
$tmp_uniq = explode(“.”,$data_cdr[‘uniqueid’]);

$rec_dir = “/var/spool/asterisk/monitor/mixed-calls/”.$tmp_date[‘0’].”/”.$tmp_date[‘1’].”/”.$tmp_date[‘2’];
if (file_exists($rec_dir)){
$files = scandir($rec_dir);
foreach($files as $file){
if (substr($file,-3) == “wav”){
$tmp = explode(“_”,$file);
$file_channel = $tmp[‘4’];
if ($file_channel == $tmp_uniq[‘0’]){
$recordingfile = “/var/spool/asterisk/monitor/mixed-calls/mixed-calls/”.$tmp_date[‘0’].”/”.$tmp_date[‘1’].”/”.$tmp_date[‘2’].”/”.$file;
$up_query = “UPDATE cdr SET dst = ‘”.$tmp[‘1’].”‘, recordingfile = ‘”.$recordingfile.”‘ WHERE uniqueid = ‘”.$data_cdr[‘uniqueid’].”‘”;
echo $up_query.”\n”;
$res = mysql_query($up_query) or die($up_query.” => “.mysql_error());
//die($res.” — “.$up_query);
}
}
}
}
}

?>

This is also my modified dialplan on the extensions_custom.conf file




[from-cucm]

exten => 1111200,1,Answer exten => 1111200,n,Noop( SIPCALLID ${SIPCALLID}) exten => 1111200,n,Noop( UNIQUEID ${UNIQUEID}) exten => 1111200,n,Noop( SIPHEADER From = _${SIP_HEADER(From)}_) exten => 1111200,n,Noop( SIPHEADER From = _${CUT(CUT(SIP_HEADER(From),\;,7),>,1)}_) exten => 1111200,n,Set(remotedid=${CUT(CUT(SIP_HEADER(From),=,6),>,1)}) exten => 1111200,n,Set(pseudodidi2=${CUT(SIP_HEADER(From),x-farendaddr,1)}) exten => 1111200,n,Noop( ${remotedid}) exten => 1111200,n,Set(File_Record=${CALLERID(num)}_${remotedid}_${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}_${CUT(SIPCALLID,-,1)}_${CUT(UNIQUEID,.,1)}_${CHANNEL:-2}%d:wav) exten => 1111200,n,Record(/var/spool/asterisk/monitor/active-calls/${File_Record},,,kq) exten => 111200,n,Hangup() #exten => h,1,Set(result=${SHELL(bash /var/spool/asterisk/tmp/script.sh ${File_Record})}) exten => h,1,System(/bin/mv /var/spool/asterisk/monitor/active-calls/${CALLERID(num)}_${remotedid}_*_${CUT(SIPCALLID,-,1)}* /var/spool/asterisk/monitor/completed-calls/) exten => h,2,NoOp(result is ${result})