Greetings,
We are working on a script that will call a call monitoring php script sending the CDR and the GROUP ID to the script and then we will do additional processing (example send SMS to relevant persons or e-mail alerts, lookup the CDR in our databases etc.).
I would appreciate insights on the best way to do this in the FreePBX context of modifying the files.
At the moment we had an asterisk engineer get it working by:
Modifying /var/lib/asterisk/agi-bin/dialparties.agi
Modifying /etc/asterisk/sip_registrations_custom.conf
Then adding the new custom ring group that triggers the alert to the respective group.
It was working for a while but then stopped working.
Here is what we did to the agi script:
// Start with Arg Count set to 3 as two args are used
$arg_cnt = 3;
while($arg = get_var($AGI,"ARG". $arg_cnt)) {
// not sure why, dialparties will get stuck in a loop if noresponse
if ($arg == '-') {
debug("get_variable got a \"noresponse\"! Exiting",3);
exit($arg_cnt);
}
$extarray = preg_split( '/-/', $arg );
foreach ( $extarray as $k ) {
$ext[] = $k;
debug("Added extension $k to extension map", 3);
if ($k == 1501){
$notifygroup = 1000; }
elseif ($k = 1502) {
$notifygroup = 1400; }
elseif ($k = 1503) {
$notifygroup2 = 1003; }
elseif ($k = 1504) {
$notifygroup2 = 1401; }
elseif ($k = 1505) {
$notifygroup2 = 1402; }
}
$arg_cnt++;
}
if ($notifygroup != 0) {
$curl = curl_init("http://OURSITEGOESHERE/callmonitor.php?CDR=$cidnum&group=$notifygroup");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
debug("NOTIFIED GROUP $notifygroup WITH NUMBER $cidnum", 3);
}
if ($notifygroup2 != 0) {
$curl = curl_init("http:/OURSITEGOES HERE/callmonitors/terrafirma.php?CDR=$cidnum&group=$notifygroup2");
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
$result = curl_exec($curl);
debug("NOTIFIED GROUP $notifygroup2 WITH NUMBER $cidnum", 3);
}
And:
To registrations_custom we did:
register=1501:PASSWORD@127.0.0.1/1501
register=1502:PASSWORD@127.0.0.1/1502
ETC. FOR OTHERS
It worked fine for a while but then stopped I think when I updated FreePBX.
I would appreciate insights from the community experts please and also best and most elegant way to acheive the same.
Martin