Added BETA support for ConfBridge with Asterisk 16 and VICIdial

git-svn-id: svn://192.168.202.10@3623 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2022-08-27 12:38:15 +00:00
parent 938186866b
commit 2f0885fae3
11 changed files with 2203 additions and 2 deletions
@@ -0,0 +1,445 @@
--- ADMIN_keepalive_ALL.pl.old 2022-08-26 15:53:26.415030606 -0400
+++ ADMIN_keepalive_ALL.pl 2022-08-26 15:53:09.559088829 -0400
@@ -438,6 +438,7 @@
# 9 - Timeclock auto logout\n";
# E - Email parser script
# S - SIP Logger
+# C - Conference Updater
# - Other setting are set by configuring them in the database
# Customized Variables
@@ -485,7 +486,7 @@
if ($DBXXX > 0) {print "SYSTEM SETTINGS: $sounds_central_control_active|$active_voicemail_server|$SScustom_dialplan_entry|$SSdefault_codecs\n";}
##### Get the settings for this server's server_ip #####
-$stmtA = "SELECT active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,asterisk_version,sounds_update,conf_secret,custom_dialplan_entry,auto_restart_asterisk,asterisk_temp_no_restart,gather_asterisk_output,conf_qualify FROM servers where server_ip='$server_ip';";
+$stmtA = "SELECT active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,asterisk_version,sounds_update,conf_secret,custom_dialplan_entry,auto_restart_asterisk,asterisk_temp_no_restart,gather_asterisk_output,conf_qualify,conf_engine FROM servers where server_ip='$server_ip';";
# print "$stmtA\n";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -504,12 +505,17 @@
$asterisk_temp_no_restart = $aryA[8];
$gather_asterisk_output = $aryA[9];
$conf_qualify = $aryA[10];
+ $conf_engine = $aryA[11];
}
$sthA->finish();
%ast_ver_str = parse_asterisk_version($asterisk_version);
if ($DBX) {print "Asterisk version: $ast_ver_str{major} $ast_ver_str{minor}\n";}
+$vicidial_conf_table = 'vicidial_conferences';
+if ( $conf_engine eq "CONFBRIDGE" ) { $vicidial_conf_table = 'vicidial_confbridge'; }
+if ($DBX) {print "Server is using $conf_engine for conferences. Conference table is $vicidial_conf_table\n";}
+
if ($VARactive_keepalives =~ /X/)
{
if ($DB) {print "X in active_keepalives, skipping this section...\n";}
@@ -540,6 +546,7 @@
$runningemail_inbound=0;
$runningASTERISK=0;
$runningsip_logger=0;
+ $runningconf_updater=0;
$AST_conf_3way=0;
if ($VARactive_keepalives =~ /1/)
@@ -597,6 +604,11 @@
$sip_logger=1;
if ($DB) {print "Check to see if sip logger should run\n";}
}
+ if ($VARactive_keepalives =~ /C/)
+ {
+ $conf_updater=1;
+ if ($DB) {print "Check to see if conference updater should run\n";}
+ }
if ($cu3way > 0)
{
$AST_conf_3way=1;
@@ -631,69 +643,74 @@
if ($psoutput[$i] =~ /bin\/asterisk/)
{
$runningASTERISK++;
- if ($DB) {print "asterisk RUNNING: |$psoutput[$i]|\n";}
+ if ($DB) {print "asterisk RUNNING: |$psoutput[$i]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_update/)
{
$runningAST_update++;
- if ($DB) {print "AST_update RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_update RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /AST_manager_se/)
{
$runningAST_send++;
- if ($DB) {print "AST_send RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_send RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /AST_manager_li/)
{
$psoutput[$i] =~ s/ .*|\n|\r|\t| //gi;
$listen_pid[$runningAST_listen] = $psoutput[$i];
$runningAST_listen++;
- if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_manager_sip_AMI2\.pl/)
{
$runningsip_logger++;
- if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";}
+ }
+ if ($psline[1] =~ /$REGhome\/AST_conf_update_screen\.pl/)
+ {
+ $runningconf_updater++;
+ if ($DB) {print "Conference Updater RUNNING: |$spline[1]\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/)
{
$runningAST_VDauto_dial++;
- if ($DB) {print "AST_VDauto_dial RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_VDauto_dial RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDremote_agents\.pl/)
{
$runningAST_VDremote_agents++;
- if ($DB) {print "AST_VDremote_agents RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_VDremote_agents RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDadapt\.pl/)
{
$runningAST_VDadapt++;
- if ($DB) {print "AST_VDadapt RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_VDadapt RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/FastAGI_log\.pl/)
{
$runningFastAGI_log++;
- if ($DB) {print "FastAGI_log RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "FastAGI_log RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDauto_dial_FILL\.pl/)
{
$runningAST_VDauto_dial_FILL++;
- if ($DB) {print "AST_VDauto_dial_FILL RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_VDauto_dial_FILL RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/VD_email_inbound\.pl/)
{
$runningemail_inbound++;
- if ($DB) {print "VD_email_inbound RUNNING:|$psline[1]|\n";}
+ if ($DB) {print "VD_email_inbound RUNNING: |$psline[1]|\n";}
}
if ($psoutput[$i] =~ / ip_relay /)
{
$runningip_relay++;
- if ($DB) {print "ip_relay RUNNING: |$psoutput[$i]|\n";}
+ if ($DB) {print "ip_relay RUNNING: |$psoutput[$i]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_conf_update_3way\.pl/)
{
$runningAST_conf_3way++;
- if ($DB) {print "AST_conf_3way RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_conf_3way RUNNING: |$psline[1]|\n";}
}
$i++;
@@ -732,7 +749,7 @@
if ($psline[1] =~ /AST_manager_li/)
{
$listen_pid[$runningAST_listen] = $psoutput[$i];
- if ($DB) {print "AST_listen RUNNING: |$psline[1]|$listen_pid[$runningAST_listen]|\n";}
+ if ($DB) {print "AST_listen RUNNING: |$psline[1]|$listen_pid[$runningAST_listen]|\n";}
$runningAST_listen++;
}
@@ -768,7 +785,8 @@
( ($ip_relay > 0) && ($runningip_relay < 1) ) ||
( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) ||
( ($email_inbound > 0) && ($runningemail_inbound < 1) ) ||
- ( ($sip_logger > 0) && ($runningsip_logger < 1) )
+ ( ($sip_logger > 0) && ($runningsip_logger < 1) ) ||
+ ( ($conf_updater > 0) && ($runningconf_updater < 1) )
)
{
@@ -794,67 +812,72 @@
if ($psoutput2[$i] =~ /bin\/asterisk/)
{
$runningASTERISK++;
- if ($DB) {print "asterisk RUNNING: |$psoutput2[$i]|\n";}
+ if ($DB) {print "asterisk RUNNING: |$psoutput2[$i]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_update/)
{
$runningAST_update++;
- if ($DB) {print "AST_update RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_update RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /AST_manager_se/)
{
$runningAST_send++;
- if ($DB) {print "AST_send RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_send RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /AST_manager_li/)
{
$runningAST_listen++;
- if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_manager_sip_AMI2\.pl/)
{
$runningsip_logger++;
- if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";}
+ }
+ if ($psline[1] =~ /$REGhome\/AST_conf_update_screen\.pl/)
+ {
+ $runningconf_updater++;
+ if ($DB) {print "Conference Updater RUNNING: |$spline[1]\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/)
{
$runningAST_VDauto_dial++;
- if ($DB) {print "AST_VDauto_dial RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_VDauto_dial RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDremote_agents\.pl/)
{
$runningAST_VDremote_agents++;
- if ($DB) {print "AST_VDremote_agents RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_VDremote_agents RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDadapt\.pl/)
{
$runningAST_VDadapt++;
- if ($DB) {print "AST_VDadapt RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_VDadapt RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/FastAGI_log\.pl/)
{
$runningFastAGI_log++;
- if ($DB) {print "FastAGI_log RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "FastAGI_log RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_VDauto_dial_FILL\.pl/)
{
$runningAST_VDauto_dial_FILL++;
- if ($DB) {print "AST_VDauto_dial_FILL RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_VDauto_dial_FILL RUNNING: |$psline[1]|\n";}
}
if ($psline[1] =~ /$REGhome\/VD_email_inbound\.pl/)
{
$runningemail_inbound++;
- if ($DB) {print "VD_email_inbound RUNNING:|$psline[1]|\n";}
+ if ($DB) {print "VD_email_inbound RUNNING: |$psline[1]|\n";}
}
if ($psoutput2[$i] =~ / ip_relay /)
{
$runningip_relay++;
- if ($DB) {print "ip_relay RUNNING: |$psoutput2[$i]|\n";}
+ if ($DB) {print "ip_relay RUNNING: |$psoutput2[$i]|\n";}
}
if ($psline[1] =~ /$REGhome\/AST_conf_update_3way\.pl/)
{
$runningAST_conf_3way++;
- if ($DB) {print "AST_conf_3way RUNNING: |$psline[1]|\n";}
+ if ($DB) {print "AST_conf_3way RUNNING: |$psline[1]|\n";}
}
$i++;
}
@@ -930,6 +953,18 @@
}
}
+ if ( ($conf_updater > 0) && ($runningconf_updater < 1) )
+ {
+ if ($DB) {print "starting Conference Updater...\n";}
+ # add a '-L' to the command below to activate logging
+ `/usr/bin/screen -d -m -S ASTConfUpdater $PATHhome/AST_conf_update_screen.pl $debug_string`;
+ if ($megaDB)
+ {
+ `/usr/bin/screen -S ASTConfUpdater -X logfile $PATHlogs/ASTconf-updater-screenlog.0`;
+ `/usr/bin/screen -S ASTConfUpdater -X log`;
+ }
+ }
+
if ( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) )
{
if ($DB) {print "starting AST_VDremote_agents...\n";}
@@ -1061,9 +1096,9 @@
}
$sthA->finish();
- if ($DB) {print "Starting clear out non-used vicidial_conferences sessions process...\n";}
+ if ($DB) {print "Starting clear out non-used $vicidial_conf_table sessions process...\n";}
- $stmtA = "SELECT conf_exten,extension from vicidial_conferences where server_ip='$server_ip' and leave_3way='0';";
+ $stmtA = "SELECT conf_exten,extension from $vicidial_conf_table where server_ip='$server_ip' and leave_3way='0';";
if ($DB) {print "|$stmtA|\n";}
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
@@ -1096,14 +1131,14 @@
if ($live_session < 1)
{
- $stmtA = "UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$k]';";
+ $stmtA = "UPDATE $vicidial_conf_table set extension='' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$k]';";
if($DBX){print STDERR "\n|$stmtA|\n";}
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
$conf_cleared = ($conf_cleared + $affected_rows);
}
$k++;
}
- if ($teodDB) {$event_string = "Empty vicidial_conferences entries cleared: $conf_cleared"; &teod_logger;}
+ if ($teodDB) {$event_string = "Empty $vicidial_conf_table entries cleared: $conf_cleared"; &teod_logger;}
### Only run the following on one server in the cluster, the one set as the active voicemail server ###
@@ -2692,9 +2727,14 @@
$Lext .= "; Agent session audio playback meetme entry\n";
$Lext .= "exten => _473782178600XXX,1,Meetme(\${EXTEN:8},q)\n";
$Lext .= "exten => _473782178600XXX,n,Hangup()\n";
+ $Lext .= "; Agent session audio playback ConfBridge entry\n";
+ $Lext .= "exten => _473782178600XXX,n,ConfBridge(\${EXTEN:8},vici_agent_bridge,vici_audio_user)\n";
+ $Lext .= "exten => _473782178600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback loop\n";
$Lext .= "exten => _473782168600XXX,1,Dial(\${TRUNKplay}/47378217\${EXTEN:8},5,To)\n";
$Lext .= "exten => _473782168600XXX,n,Hangup()\n";
+ $Lext .= "exten => _473782169600XXX,1,Dial(\${TRUNKplay}/47378217\${EXTEN:8},5,To)\n";
+ $Lext .= "exten => _473782169600XXX,n,Hangup()\n";
$Lext .= "; Agent session audio playback extension\n";
$Lext .= "exten => 473782158521111,1,Answer\n";
$Lext .= "exten => 473782158521111,n,ControlPlayback(\${CALLERID(name)},99999,0,1,2,3,4)\n";
@@ -2715,6 +2755,14 @@
$Lext .= "exten => _473782188600XXX,n,GotoIf(\$[ \"\${agent_zap_channel}\" = \"101\" ]?fin)\n";
$Lext .= "exten => _473782188600XXX,n,ChanSpy(\${agent_zap_channel},qw)\n";
$Lext .= "exten => _473782188600XXX,n(fin),Hangup()\n";
+ $Lext .= "; Whisper to agent ConfBridge entry\n";
+ $Lext .= "exten => _473782189600XXX,1,Answer\n";
+ $Lext .= "exten => _473782189600XXX,n,Wait(1)\n";
+ $Lext .= "exten => _473782189600XXX,n,AGI(getAGENTchannel.agi)\n";
+ $Lext .= "exten => _473782189600XXX,n,NoOp(\${agent_zap_channel})\n";
+ $Lext .= "exten => _473782189600XXX,n,GotoIf(\$[ \"\${agent_zap_channel}\" = \"101\" ]?fin)\n";
+ $Lext .= "exten => _473782189600XXX,n,ChanSpy(\${agent_zap_channel},qw)\n";
+ $Lext .= "exten => _473782189600XXX,n(fin),Hangup()\n";
}
$Lext .= "\n";
@@ -3782,6 +3830,7 @@
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$i=0;
+ if ($DBX>0) {print "$sthArows|$stmtA\n";}
while ($sthArows > $i)
{
@aryA = $sthA->fetchrow_array;
@@ -4376,53 +4425,56 @@
##### END generate voicemail accounts for all distinct phones on dedicated voicemail server
-
+
##### BEGIN generate meetme entries for this server
- $mm = "; ViciDial Conferences:\n";
-
- ### Find vicidial_conferences on this server
- $stmtA = "SELECT conf_exten FROM vicidial_conferences where server_ip='$server_ip';";
- $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
- $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
- $sthArowsVC=$sthA->rows;
- $j=0;
- while ($sthArowsVC > $j)
+ if ($conf_engine eq "MEETME")
{
- @aryA = $sthA->fetchrow_array;
- $vc_meetme[$j] = $aryA[0];
- $j++;
- }
- $sthA->finish();
-
- $j=0;
- while ($sthArowsVC > $j)
- {
- $mm .= "conf => $vc_meetme[$j]\n";
- $j++;
- }
-
- $mm .= "\n";
- $mm .= "; Conferences:\n";
+ $mm = "; ViciDial Conferences:\n";
+
+ ### Find vicidial_conferences on this server
+ $stmtA = "SELECT conf_exten FROM vicidial_conferences where server_ip='$server_ip';";
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $sthArowsVC=$sthA->rows;
+ $j=0;
+ while ($sthArowsVC > $j)
+ {
+ @aryA = $sthA->fetchrow_array;
+ $vc_meetme[$j] = $aryA[0];
+ $j++;
+ }
+ $sthA->finish();
+
+ $j=0;
+ while ($sthArowsVC > $j)
+ {
+ $mm .= "conf => $vc_meetme[$j]\n";
+ $j++;
+ }
+
+ $mm .= "\n";
+ $mm .= "; Conferences:\n";
- ### Find conferences on this server
- $stmtA = "SELECT conf_exten FROM conferences where server_ip='$server_ip';";
- $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
- $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
- $sthArowsC=$sthA->rows;
- $j=0;
- while ($sthArowsC > $j)
- {
- @aryA = $sthA->fetchrow_array;
- $meetme[$j] = $aryA[0];
- $j++;
- }
- $sthA->finish();
+ ### Find conferences on this server
+ $stmtA = "SELECT conf_exten FROM conferences where server_ip='$server_ip';";
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $sthArowsC=$sthA->rows;
+ $j=0;
+ while ($sthArowsC > $j)
+ {
+ @aryA = $sthA->fetchrow_array;
+ $meetme[$j] = $aryA[0];
+ $j++;
+ }
+ $sthA->finish();
- $j=0;
- while ($sthArowsC > $j)
- {
- $mm .= "conf => $meetme[$j]\n";
- $j++;
+ $j=0;
+ while ($sthArowsC > $j)
+ {
+ $mm .= "conf => $meetme[$j]\n";
+ $j++;
+ }
}
##### END generate meetme entries for this server
@@ -4878,7 +4930,7 @@
if ($screenoutput[$i] =~ /\.asterisk/)
{
$asteriskSCREEN++;
- if ($DB) {print "asterisk screen session open: |$screenoutput[$i]|\n";}
+ if ($DB) {print "asterisk screen session open: |$screenoutput[$i]|\n";}
}
$i++;
}
@@ -0,0 +1,14 @@
--- ADMIN_update_server_ip.pl.old 2022-08-26 15:58:07.510059960 -0400
+++ ADMIN_update_server_ip.pl 2022-08-26 15:57:50.982117018 -0400
@@ -445,6 +445,11 @@
$affected_rows = $dbhA->do($stmtA);
if ($DB) {print " |$affected_rows|$stmtA|\n";}
+print " Updating vicidial_confbridges table...\n";
+$stmtA = "UPDATE vicidial_confbridges SET server_ip='$VARserver_ip' where server_ip='$VARold_server_ip';";
+$affected_rows = $dbhA->do($stmtA);
+if ($DB) {print " |$affected_rows|$stmtA|\n";}
+
print " Updating vicidial_stations table...\n";
$stmtA = "UPDATE vicidial_stations SET server_ip='$VARserver_ip' where server_ip='$VARold_server_ip';";
$affected_rows = $dbhA->do($stmtA);
+22
View File
@@ -0,0 +1,22 @@
--- AST_DB_optimize.pl.old 2022-08-26 16:00:06.989647473 -0400
+++ AST_DB_optimize.pl 2022-08-26 15:59:47.605714442 -0400
@@ -293,6 +293,19 @@
$sthA->finish();
}
+$stmtA = "optimize table vicidial_confbridges;";
+if($DB){print STDERR "\n|$stmtA|\n";}
+if (!$T)
+ {
+ $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
+ $sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
+ $sthArows=$sthA->rows;
+ @aryA = $sthA->fetchrow_array;
+ if (!$q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
+ $sthA->finish();
+ }
+
+
$stmtA = "optimize table vicidial_hopper;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
+868
View File
@@ -0,0 +1,868 @@
#!/usr/bin/perl
#
# AST_conf_update_screen.pl version 2.14
#
# This script uses the Asterisk Manager interface to update the live_channels
# tables and verify the parked_channels table in the asterisk MySQL database
#
# Copyright (C) 2021 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 220414-1210 - Initial build
#
# constants
$DB=0; # Debug flag, set to 0 for no debug messages, lots of output
$DBX=0;
$run_check=1; # concurrency check
# loop time in seconds
$loop_time = 0.4;
# how often settings should be reloaded from the DB in seconds
$settings_reload_interval = 10;
# how often to purge the conference records
$conf_purge_interval = 15;
### begin parsing run-time options ###
if (length($ARGV[0])>1)
{
$i=0;
while ($#ARGV >= $i)
{
$args = "$args $ARGV[$i]";
$i++;
}
if ($args =~ /--help/i)
{
print "allowed run time options:\n";
print " [--test] = test\n";
print " [--debug] = verbose debug messages\n";
print " [--debugX] = Extra-verbose debug messages\n";
print " [--help] = this screen\n";
print "\n";
exit;
}
else
{
if ($args =~ /--debug/i)
{
$DB=1; # Debug flag
print "\n----- DEBUGGING ENABLED -----\n\n";
}
if ($args =~ /--debugX/i)
{
$DBX=1;
print "\n----- SUPER-DUPER DEBUGGING -----\n\n";
}
if ($args =~ /--test/i)
{
$TEST=1;
$T=1;
}
}
}
### end parsing run-time options ###
# default path to astguiclient configuration file:
$PATHconf = '/etc/astguiclient.conf';
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
@conf = <conf>;
close(conf);
$i=0;
foreach(@conf)
{
$line = $conf[$i];
$line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi;
if ($line =~ /^PATHhome/) {$PATHhome = $line; $PATHhome =~ s/.*=//gi;}
if ($line =~ /^PATHlogs/) {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;}
if ($line =~ /^PATHagi/) {$PATHagi = $line; $PATHagi =~ s/.*=//gi;}
if ($line =~ /^PATHweb/) {$PATHweb = $line; $PATHweb =~ s/.*=//gi;}
if ($line =~ /^PATHsounds/) {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;}
if ($line =~ /^PATHmonitor/) {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;}
if ($line =~ /^VARserver_ip/) {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;}
if ($line =~ /^VARDB_server/) {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;}
if ($line =~ /^VARDB_database/) {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;}
if ($line =~ /^VARDB_user/) {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;}
if ($line =~ /^VARDB_pass/) {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;}
if ($line =~ /^VARDB_custom_user/) {$VARDB_custom_user = $line; $VARDB_custom_user =~ s/.*=//gi;}
if ($line =~ /^VARDB_custom_pass/) {$VARDB_custom_pass = $line; $VARDB_custom_pass =~ s/.*=//gi;}
if ($line =~ /^VARDB_port/) {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;}
$i++;
}
# Customized Variables
$server_ip = $VARserver_ip; # Asterisk server IP
if (!$VARDB_port) {$VARDB_port='3306';}
&get_time_now;
#use lib './lib', '../lib';
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
use DBI;
use Net::Telnet ();
use Switch;
use POSIX;
use Scalar::Util qw(looks_like_number);
use Term::ANSIColor qw(:constants);
$module = 'String::Escape qw( backslash unbackslash )';
$bs_loaded=0;
if (try_load($module))
{
$bs_loaded=1;
}
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
or die "Couldn't connect to database: " . DBI->errstr;
### Grab Server values from the database
$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs,asterisk_version,conf_engine,conf_update_interval,vicidial_recording_limit FROM servers where server_ip = '$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$DBtelnet_host = $aryA[0];
$DBtelnet_port = $aryA[1];
$DBASTmgrUSERNAME = $aryA[2];
$DBASTmgrSECRET = $aryA[3];
$DBASTmgrUSERNAMEupdate = $aryA[4];
$DBASTmgrUSERNAMElisten = $aryA[5];
$DBASTmgrUSERNAMEsend = $aryA[6];
$DBmax_vicidial_trunks = $aryA[7];
$DBanswer_transfer_agent= $aryA[8];
$DBSERVER_GMT = $aryA[9];
$DBext_context = $aryA[10];
$DBvd_server_logs = $aryA[11];
$asterisk_version = $aryA[12];
$conf_engine = $aryA[13];
$conf_update_interval = $aryA[14];
$vicidial_recording_limit = $aryA[15];
if ($DBtelnet_host) {$telnet_host = $DBtelnet_host;}
if ($DBtelnet_port) {$telnet_port = $DBtelnet_port;}
if ($DBASTmgrUSERNAME) {$ASTmgrUSERNAME = $DBASTmgrUSERNAME;}
if ($DBASTmgrSECRET) {$ASTmgrSECRET = $DBASTmgrSECRET;}
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
if ($DBASTmgrUSERNAMEupdate) {$ASTmgrUSERNAMEupdate = $DBASTmgrUSERNAMEupdate;}
if ($DBASTmgrUSERNAMEsend) {$ASTmgrUSERNAMEsend = $DBASTmgrUSERNAMEsend;}
if ($DBmax_vicidial_trunks) {$max_vicidial_trunks = $DBmax_vicidial_trunks;}
if ($DBanswer_transfer_agent) {$answer_transfer_agent = $DBanswer_transfer_agent;}
if ($DBSERVER_GMT) {$SERVER_GMT = $DBSERVER_GMT;}
if ($DBext_context) {$ext_context = $DBext_context;}
if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';}
else {$SYSLOG = '0';}
if ($vicidial_recording_limit < 60) {$vicidial_recording_limit=60;}
}
if (!$telnet_port) {$telnet_port = '5038';}
$loop_time = $conf_update_interval;
##### Find date-time one hour in the past
$secX = time();
$TDtarget = ($secX - ($vicidial_recording_limit * 60));
($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime($TDtarget);
$Tyear = ($Tyear + 1900);
$Tmon++;
if ($Tmon < 10) {$Tmon = "0$Tmon";}
if ($Tmday < 10) {$Tmday = "0$Tmday";}
if ($Thour < 10) {$Thour = "0$Thour";}
if ($Tmin < 10) {$Tmin = "0$Tmin";}
if ($Tsec < 10) {$Tsec = "0$Tsec";}
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
$TDrand = int( rand(99)) + 100;
$TDnum = "$Tmon$Tmday$Thour$Tmin$Tsec$TDrand";
$TDinc = 1;
### concurrency check (SCREEN uses script path, so check for more than 2 entries)
if ($run_check > 0)
{
my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`;
my $grepnum=0;
$grepnum++ while ($grepout =~ m/\n/g);
if ($grepnum > 2)
{
if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";}
$event_string = "I am not alone! Another $0 is running! Exiting...";
&event_logger($SYSLOG,$event_string);
exit;
}
}
$event_string="STARTING NEW MANAGER TELNET CONNECTION||ATTEMPT|ONE DAY INTERVAL:$one_day_interval|";
event_logger($SYSLOG,$event_string);
$max_buffer = 4*1024*1024; # 4 meg buffer
### connect to asterisk manager through telnet
$tn = new Net::Telnet (
Port => $telnet_port,
Prompt => '/\r\n/',
Output_record_separator => "\n\n",
Max_buffer_length => $max_buffer,
Telnetmode => 0,
);
$UPtelnetlog = "$PATHlogs/conf_telnet_log.txt"; # uncomment for telnet log
$fh = $tn->dump_log("$UPtelnetlog"); # uncomment for telnet log
$telnet_login = "confcron";
$tn->open("$telnet_host");
$tn->waitfor('/Asterisk Call Manager\//');
# get the AMI version number
$ami_version = $tn->getline(Errmode => Return, Timeout => 1,);
$ami_version =~ s/\n//gi;
print "----- AMI Version $ami_version -----\n";
# Login
$tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET");
$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted
$tn->buffer_empty;
$event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|AMI Version $ami_version|ONE DAY INTERVAL:$one_day_interval|";
event_logger($SYSLOG,$event_string);
%ast_ver_str = parse_asterisk_version($asterisk_version);
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 13))
{
print "Asterisk version too low for this script. Exiting.\n\n\n";
$event_string = "Asterisk version too low for this script. Exiting.";
&event_logger($SYSLOG,$event_string);
exit;
}
else
{
### BEGIN manager event handling for asterisk version >= 13
$endless_loop = 1;
$loop_count = 0;
# get the number of microseconds the loop is supposed to take
$loop_time_usec = $loop_time * 1000000;
$loop_time_usec = ceil($loop_time_usec); # take care of any floating point math
# the last time our settings were loaded from the DB
$last_config_reload = 0;
# last time we purged conferences
$last_conf_purge = 0;
while($endless_loop)
{
# increment total loop counter
$loop_count++;
$total_rooms = 0;
# get the current time
( $now_sec, $now_micro_sec ) = gettimeofday();
# figure out how many micro seconds since epoch
$now_micro_epoch = $now_sec * 1000000;
$now_micro_epoch = $now_micro_epoch + $now_micro_sec;
$begin_micro_epoch = $now_micro_epoch;
# create a new action id
$action_id = "$now_sec.$now_micro_sec";
$modechange = $tn->errmode('return');
@room_array = ();
if ( $conf_engine eq "MEETME" )
{
# ask the AMI for the conferences
$action_string = "Action: MeetmeListRooms\nActionID: $action_id";
$tn->print($action_string);
# wait till we get the response
$pattern = '/Message: Meetme conferences will follow\n\n|Message: No active conferences.\n\n/';
}
else
{
# ask the AMI for the conferences
$action_string = "Action: ConfbridgeListRooms\nActionID: $action_id";
$tn->print($action_string);
# wait till we get the response
$pattern = '/Message: Confbridge conferences will follow\n\n|Message: No active conferences.\n\n/';
}
( $read_input_buf, $match ) = $tn->waitfor($pattern);
$msg = $tn->errmsg;
if ( $msg ne '' )
{
$event_string = "WAITFOR ERRMSG: |$msg|$now_date|" . length($read_input_buf) . "|$endless_loop|$loop_count|Command:\n\n$action_string\n\nPattern:$pattern\n\n";
&event_logger($SYSLOG,$event_string);
print $event_string."\n";
}
&get_time_now;
print "\n\n$now_date\n|$conf_engine List:\n";
event_logger($SYSLOG,"$conf_engine List:");
if ($match eq "Message: No active conferences.\n\n")
{
print "|No active conferences.\n";
$event_string = "|No active conferences.";
event_logger($SYSLOG,$event_string);
}
else
{
# Loop to get all of the channels
$event_ref = {};
if ( $conf_engine eq "MEETME" )
{
$match_string = '/Event: MeetmeListRoomsComplete\nActionID: ' . $action_id . '\nEventList: Complete\nListItems: \d+/';
}
else
{
$match_string = '/Event: ConfbridgeListRoomsComplete\nActionID: ' . $action_id . '\nEventList: Complete\nListItems: \d+/';
}
# get an entire record
( $read_input_buf, $match ) = $tn->waitfor(Errmode => Return, Timeout => 1, Match => "$match_string");
chomp( $read_input_buf );
if (($bs_loaded) && (length($read_input_buf) > 0))
{
if ($DBX) { print "|read|" . backslash( $read_input_buf ) . "|\n"; }
event_logger($SYSLOG,"|read|" . backslash( $read_input_buf ) . "|");
if ($DBX) { print "|match|" . backslash( $match ) . "|\n"; }
event_logger($SYSLOG,"|match|" . backslash( $match ) . "|");
}
( $junk, $list_items) = split( /ListItems: /, $match );
if ($DBX)
{
print "|total_rooms|$list_items\n";
&event_logger($SYSLOG,"|total_rooms|$list_items");
}
# check if there were any errors
$msg='';
$msg = $tn->errmsg;
if ( ( $msg ne '' ) && ( $msg !~ /read timed-out/i ) )
{
if ($msg =~ /filehandle isn\'t open/i)
{
# we have lost connection
$endless_loop=0;
$one_day_interval=0;
print "ERRMSG: |$msg|$now_date|" . length($read_input_buf) . "|$endless_loop|$loop_count|\n";
print "\nAsterisk server shutting down, PROCESS KILLED... EXITING\n\n";
$event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|$msg|";
event_logger($SYSLOG,$event_string);
}
else
{
# something happened
print "ERRMSG: |$msg|$now_date|" . length($read_input_buf) . "|$endless_loop|$loop_count|Command: $action_string|Match String: $match_string|\n";
$bad_grab = 1;
}
}
else
{
@records = split( /\n\n/, $read_input_buf );
foreach my $record ( @records )
{
# Loop to get all of the channels
$event_ref = {};
# break the record into lines
@lines = split( /\n/, $record );
foreach my $line ( @lines)
{
# add the line to the hash
($key,$value) = split( /: /, $line );
if ($key ne "")
{
$value =~ s/\n//gi; # remove new lines
$value =~ s/^ +//gi; # remove leading white space
$value =~ s/ +$//gi; # remove trailing white space
$event_ref->{"$key"} = $value;
}
}
$hash_size = keys(%$event_ref);
if ( $hash_size > 2 )
{
$debug_string = '';
if ( $event_ref->{'Event'} eq "MeetmeListRooms" )
{
if ( $total_rooms == 0 )
{
$debug_string .= "|Conference|Parties|Marked|Activity|Creation|Locked|";
print "$debug_string\n";
event_logger($SYSLOG,$debug_string);
$debug_string = '';
}
$debug_string .= "|$event_ref->{'Conference'}";
$debug_string .= "|$event_ref->{'Parties'}";
$debug_string .= "|$event_ref->{'Marked'}";
$debug_string .= "|$event_ref->{'Activity'}";
$debug_string .= "|$event_ref->{'Creation'}";
$debug_string .= "|$event_ref->{'Locked'}";
}
if ( $event_ref->{'Event'} eq "ConfbridgeListRooms" )
{
if ( $total_rooms == 0 )
{
$debug_string .= "|Conference|Parties|Marked|Locked|Muted|";
print "$debug_string\n";
event_logger($SYSLOG,$debug_string);
$debug_string = '';
}
$debug_string .= "|$event_ref->{'Conference'}";
$debug_string .= "|$event_ref->{'Parties'}";
$debug_string .= "|$event_ref->{'Marked'}";
$debug_string .= "|$event_ref->{'Locked'}";
$debug_string .= "|$event_ref->{'Muted'}";
}
print "$debug_string\n";
event_logger($SYSLOG,$debug_string);
}
$event_ref->{'AMIVersion'} = $ami_version;
$event_ref->{'ServerIP'} = $server_ip;
$retcode = 1;
# make sure this is an event not a response
if (exists($event_ref->{"Event"}))
{
if ( ( $event_ref->{"Event"} eq "ConfbridgeListRooms" ) || ( $event_ref->{"Event"} eq "MeetmeListRooms" ) )
{
$total_rooms++;
# We got a room
if ( $event_ref->{"ActionID"} eq $action_id )
{
push( @room_array, $event_ref );
}
else
{
if ($DB) { print STDERR "We got the wrong Action ID!!!!\n"; }
}
}
else
{
# We got something else???
}
}
elsif ( exists($event_ref->{"Response"}) )
{
# we got the response. Channels should follow.
}
}
}
if ( $total_rooms != $list_items )
{
# something is wrong. we did not process the
# same number of channels as were reported.
}
if ($DB) { print STDERR "$total_rooms rooms recieved out of $list_items reported.|\n"; }
$room_array_ref = \@room_array;
}
######################################################################
##### CHECK all TABLE #####
######################################################################
%conf_hash = ();
if ( $conf_engine eq "MEETME" )
{
# get conferences table data
$stmtA = "SELECT extension,conf_exten from conferences where server_ip='$server_ip' and extension is NOT NULL and extension != '';";
if ($DB) {print "|$stmtA|\n";}
event_logger($SYSLOG,"|$stmtA|");
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$conf_hash{ "$aryA[1]" } = { "extension" => $aryA[0], "type" => "c" };
$rec_count++;
}
$sthA->finish();
# get vicidial_conferences data
$stmtA = "SELECT extension,conf_exten from vicidial_conferences where server_ip='$server_ip' and leave_3way='1';";
if ($DB) {print "|$stmtA|\n";}
event_logger($SYSLOG,"|$stmtA|");
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$conf_hash{ "$aryA[1]" } = { "extension" => $aryA[0], "type" => "vc" };
$rec_count++;
}
$sthA->finish();
}
else
{
# get vicidial_confbridges data
$stmtA = "SELECT extension,conf_exten from vicidial_confbridges where server_ip='$server_ip' and leave_3way='1';";
if ($DB) {print "|$stmtA|\n";}
event_logger($SYSLOG,"|$stmtA|");
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$conf_hash{ "$aryA[1]" } = { "extension" => $aryA[0], "type" => "vcb" };
$rec_count++;
}
$sthA->finish()
}
# loop through the room data
foreach $room (@room_array)
{
$conf_id = $room->{'Conference'};
if (( $room->{'Parties'} == 0 ) && ($conf_hash{"$conf_id"}{"type"} eq "c"))
{
# we are just a conference so dont kicking people out
$new_exten = $conf_hash{"$conf_id"}{"extension"};
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout3$/i) {$new_exten =~ s/Xtimeout3$/Xtimeout2/gi;}
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout2$/i) {$new_exten =~ s/Xtimeout2$/Xtimeout1/gi;}
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout1$/i) {$new_exten = '';}
if ( ($conf_hash{"$conf_id"}{"extension"} !~ /Xtimeout\d$/i) and (length($conf_hash{"$conf_id"}{"extension"})> 0) ) {$new_exten .= 'Xtimeout3';}
if($DB) { print $conf_hash{"$conf_id"}{"extension"} . "|$new_exten|$leave_3waySQL|\n"; }
$stmtA = "UPDATE vicidial_conferences set extension='$new_exten' where server_ip='$server_ip' and conf_exten='$conf_id';";
if($DB){print STDERR "\n|$stmtA|\n";}
event_logger($SYSLOG,"|$stmtA|");
$affected_rows = $dbhA->do($stmtA);
}
elsif (( $room->{'Parties'} <= 1 ) && (($conf_hash{"$conf_id"}{"type"} eq "vc") || ($conf_hash{"$conf_id"}{"type"} eq "vcb")))
{
# we are a vicidial conference so we can single partisipants out.
$new_exten = $conf_hash{"$conf_id"}{"extension"};
$leave_3waySQL = '1';
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout3$/i) {$new_exten =~ s/Xtimeout3$/Xtimeout2/gi;}
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout2$/i) {$new_exten =~ s/Xtimeout2$/Xtimeout1/gi;}
if ($conf_hash{"$conf_id"}{"extension"} =~ /Xtimeout1$/i) {$new_exten = ''; $leave_3waySQL='0';}
if ( ($conf_hash{"$conf_id"}{"extension"} !~ /Xtimeout\d$/i) and (length($conf_hash{"$conf_id"}{"extension"})> 0) ) {$new_exten .= 'Xtimeout3';}
if($DB) { print $conf_hash{"$conf_id"}{"extension"} . "|$new_exten|$leave_3waySQL|\n";}
event_logger($SYSLOG, $conf_hash{"$conf_id"}{"extension"} . "|$new_exten|$leave_3waySQL|");
$kick = 0;
if ($new_exten =~ /Xtimeout1$/i)
{
### Kick all participants if there are any left in the conference so it can be reused
$local_DEF = 'Local/5555';
$local_AMP = '@';
$kick_local_channel = $local_DEF . $conf_id . $local_AMP . $ext_context;
$padTDinc = sprintf("%03s", $TDinc); while (length($padTDinc) > 3) {chop($padTDinc);}
$queryCID = "ULGC$padTDinc$TDnum";
$stmtA="INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','','');";
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
if($DB){print STDERR "\n|$affected_rows|$stmtA|\n";}
event_logger($SYSLOG,"|$affected_rows|$stmtA|");
$TDinc++;
$kick = 1;
}
if ($conf_hash{"$conf_id"}{"type"} eq "vc")
{
$stmtA = "UPDATE vicidial_conferences set extension='$new_exten',leave_3way='$leave_3waySQL' where server_ip='$server_ip' and conf_exten='$conf_id';";
}
else
{
$stmtA = "UPDATE vicidial_confbridges set extension='$new_exten',leave_3way='$leave_3waySQL' where server_ip='$server_ip' and conf_exten='$conf_id';"
}
if($DB){print STDERR "\n|$stmtA|\n";}
event_logger($SYSLOG,"\n|$stmtA|");
$affected_rows = $dbhA->do($stmtA);
# only sleep if we did a kick
if ($kick) { usleep(1*100*1000); }
}
}
# reload the settings from the DB at a fixed interval
$epoch = time();
if ( $epoch - $last_conf_purge >= $conf_purge_interval)
{
clear_conf_records();
$last_conf_purge = time();
}
# reload the settings from the DB at a fixed interval
$epoch = time();
if ( $epoch - $last_config_reload >= $settings_reload_interval )
{
# reload the server settings
$settings_ref = get_server_settings($dbhA,$server_ip);
$loop_time_usec = $settings_ref->{'conf_update_interval'} * 1000000;
$loop_time_usec = ceil($loop_time_usec); # take care of any floating point math
$vicidial_recording_limit = $settings_ref->{'vicidial_recording_limit'};
$conf_engine = $settings_ref->{'conf_engine'};
$last_config_reload = time();
}
# figure out how long that loop took.
# get the current time
( $now_sec, $now_micro_sec ) = gettimeofday();
# figure out how many micro seconds since epoch
$now_micro_epoch = $now_sec * 1000000;
$now_micro_epoch = $now_micro_epoch + $now_micro_sec;
$end_micro_epoch = $now_micro_epoch;
# subtract the current time in usec from time at the beginning of the loop
$loop_usec = $end_micro_epoch - $begin_micro_epoch;
# figure out how long to sleep
$sleep_usec = $loop_time_usec - $loop_usec;
# cannot sleep negative time
if ( $sleep_usec > 0 )
{
if ($DB) { print STDERR "loop took $loop_usec microseconds. sleeping for $sleep_usec microseconds to compensate\n"; }
event_logger($SYSLOG,"loop took $loop_usec microseconds. sleeping for $sleep_usec microseconds to compensate\n");
# sleep it
usleep($sleep_usec);
}
}
}
if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...$one_day_interval left\n";}
$event_string='HANGING UP|';
event_logger($SYSLOG,$event_string);
@hangup = $tn->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/", Errmode => Return, Timeout => 1);
$tn->buffer_empty;
$tn->waitfor(Match => '/Message:.*\n\n/', Timeout => 10);
$ok = $tn->close;
$event_string='CLOSING DB CONNECTION|';
event_logger($SYSLOG,$event_string);
$dbhA->disconnect();
if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";}
exit;
sub get_server_settings
{
my ($dbhA,$server_ip) = @_;
### Grab Server values from the database
$stmtA = "SELECT conf_engine,conf_update_interval,vicidial_recording_limit FROM servers where server_ip='$server_ip';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$settings_ref = $sthA->fetchrow_hashref;
if ($DB) { print "Settings Reload|$stmtA|$settings_ref->{'conf_engine'}|$settings_ref->{'conf_update_interval'}|$settings_ref->{'vicidial_recording_limit'}\n"; }
event_logger($SYSLOG,"Settings Reload|$stmtA|$settings_ref->{'conf_engine'}|$settings_ref->{'conf_update_interval'}|$settings_ref->{'vicidial_recording_limit'}");
return $settings_ref;
}
sub event_logger
{
my ($SYSLOG,$event_string) = @_;
if ($SYSLOG)
{
### open the log file for writing ###
open(Lout, ">>$PATHlogs/conf_update.$action_log_date")
|| die "Can't open $PATHlogs/conf_update.$action_log_date: $!\n";
print Lout "$now_date|$event_string|\n";
close(Lout);
}
$event_string='';
}
# subroutine to parse the asterisk version
# and return a hash with the various part
sub parse_asterisk_version
{
# grab the arguments
my $ast_ver_str = $_[0];
# get everything after the - and put it in $ast_ver_postfix
my @hyphen_parts = split( /-/ , $ast_ver_str );
my $ast_ver_postfix = $hyphen_parts[1];
# now split everything before the - up by the .
my @dot_parts = split( /\./ , $hyphen_parts[0] );
my %ast_ver_hash;
if ( $dot_parts[0] <= 1 )
{
%ast_ver_hash = (
"major" => $dot_parts[0],
"minor" => $dot_parts[1],
"build" => $dot_parts[2],
"revision" => $dot_parts[3],
"postfix" => $ast_ver_postfix
);
}
# digium dropped the 1 from asterisk 10 but we still need it
if ( $dot_parts[0] > 1 )
{
%ast_ver_hash = (
"major" => 1,
"minor" => $dot_parts[0],
"build" => $dot_parts[1],
"revision" => $dot_parts[2],
"postfix" => $ast_ver_postfix
);
}
return ( %ast_ver_hash );
}
sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes
{
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year = ($year + 1900);
$mon++;
if ($mon < 10) {$mon = "0$mon";}
if ($mday < 10) {$mday = "0$mday";}
if ($hour < 10) {$hour = "0$hour";}
if ($min < 10) {$min = "0$min";}
if ($sec < 10) {$sec = "0$sec";}
$now_date_epoch = time();
$now_date = "$year-$mon-$mday $hour:$min:$sec";
$action_log_date = "$year-$mon-$mday";
}
# try to load a module
sub try_load
{
my $mod = shift;
eval("use $mod");
if ($@)
{
#print "\$@ = $@\n";
return(0);
}
else
{
return(1);
}
}
sub clear_conf_records
{
######################################################################
##### CLEAR vicidial_conferences ENTRIES IN LEAVE-3WAY FOR MORE THAN ONE HOUR
######################################################################
##### Find date-time one hour in the past
$secX = time();
$TDtarget = ($secX - ($vicidial_recording_limit * 60));
($Tsec,$Tmin,$Thour,$Tmday,$Tmon,$Tyear,$Twday,$Tyday,$Tisdst) = localtime($TDtarget);
$Tyear = ($Tyear + 1900);
$Tmon++;
if ($Tmon < 10) {$Tmon = "0$Tmon";}
if ($Tmday < 10) {$Tmday = "0$Tmday";}
if ($Thour < 10) {$Thour = "0$Thour";}
if ($Tmin < 10) {$Tmin = "0$Tmin";}
if ($Tsec < 10) {$Tsec = "0$Tsec";}
$TDSQLdate = "$Tyear-$Tmon-$Tmday $Thour:$Tmin:$Tsec";
$TDrand = int( rand(99)) + 100;
$TDnum = "$Tmon$Tmday$Thour$Tmin$Tsec$TDrand";
$TDinc = 1;
@PTextensions=@MT; @PT_conf_extens=@MT; @PTmessages=@MT; @PTold_messages=@MT; @NEW_messages=@MT; @OLD_messages=@MT;
$stmtA = "SELECT conf_exten,extension from vicidial_conferences where server_ip='$server_ip' and leave_3way='1' and leave_3way_datetime < \"$TDSQLdate\";";
if ($DB) {print "Conf Purge|$stmtA|\n";}
event_logger($SYSLOG,"Conf Purge|$stmtA|");
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
$rec_count=0;
while ($sthArows > $rec_count)
{
@aryA = $sthA->fetchrow_array;
$PT_conf_extens[$rec_count] = $aryA[0];
$PT_extensions[$rec_count] = $aryA[1];
if ($DB) {print "|$PT_conf_extens[$rec_count]|$PT_extensions[$rec_count]|\n";}
$rec_count++;
}
$sthA->finish();
$k=0;
while ($k < $rec_count)
{
$local_DEF = 'Local/5555';
$local_AMP = '@';
$kick_local_channel = "$local_DEF$PT_conf_extens[$k]$local_AMP$ext_context";
$padTDinc = sprintf("%03s", $TDinc); while (length($padTDinc) > 3) {chop($padTDinc);}
$queryCID = "ULGH$padTDinc$TDnum";
$stmtA="INSERT INTO vicidial_manager values('','','$now_date','NEW','N','$server_ip','','Originate','$queryCID','Channel: $kick_local_channel','Context: $ext_context','Exten: 8300','Priority: 1','Callerid: $queryCID','','','','','');";
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
$stmtA = "UPDATE vicidial_conferences set extension='',leave_3way='0' where server_ip='$server_ip' and conf_exten='$PT_conf_extens[$k]';";
if($DB){print STDERR "\n|$stmtA|\n";}
event_logger($SYSLOG,"Conf Purge|$stmtA|");
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query:|$stmtA|\n";
$k++;
$TDinc++;
}
}
@@ -0,0 +1,14 @@
--- AST_reset_mysql_vars.pl.old 2022-08-26 16:01:47.681299321 -0400
+++ AST_reset_mysql_vars.pl 2022-08-26 16:01:30.585358428 -0400
@@ -76,6 +76,11 @@
$affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
print " - vicidial_conferences reset\n";
+ $stmtA = "UPDATE vicidial_confbridges set extension='' where server_ip='$server_ip';";
+ if($DB){print STDERR "\n|$stmtA|\n";}
+ $affected_rows = $dbhA->do($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
+ print " - vicidial_confbridges reset\n";
+
# $stmtA = "UPDATE vicidial_manager set status='DEAD' where server_ip='$server_ip' and status='NEW';";
# if($DB){print STDERR "\n|$stmtA|\n";}
# $dbhA->query($stmtA); # or die "Couldn't execute query: |$stmtA|\n";
@@ -0,0 +1,558 @@
VICIdial ConfBridge Support: STARTED: 2022-06-22 UPDATED: 2022-08-27
!!! NOTE: VICIdial ConfBridge support is currently in BETA mode and is not recommended for systems that require a stable and tested codebase !!!
!!! NOTE: VICIdial ConfBridge support requires Asterisk 16 or higher to be installed on your dialers. Code development and testing was done with VICIbox 10 and the optional Asterisk 16 package available through VICIbox 10 !!!
- Background
For the past 19 years, the core of Vicidial has been based around the MeetMe conferencing engine built into Asterisk. When an agent logs into Vicidial their phone gets called by Vicidial. When that call connects the agent gets placed into a MeetMe conference. For the most part they stay within that conference the entire time they are logged into Vicidial. It is only when they leave a consultative transfer that they get moved to a different MeetMe conference. When an agent places a Manual dial phone call, the outbound call gets connected to their MeetMe phone conference. When an auto dial phone call answers it goes through the outbound routing agi and ultimately gets routed into an agent's MeetMe phone conference. When an inbound call gets past to the inbound routing AGI script it ultimately gets routed to an agent's MeetMe phone conference. Vicidial initiates call recordings by attaching a monitoring extension to an agents MeetMe phone conference. As such Vicidial at its most basic level is designed to place channels into and remove them from MeetMe phone conferences.
As such when Digium announced that they would be removing the MeetMe conferencing engine from the Asterisk code base in favor of their ConfBridge application, it meant a major change to Vicidial. The web interface code needed to be updated. The routing scripts needed to be updated. The core process monitoring scripts needed to be updated. The Asterisk dialplan needed to be updated. ConfBridge does have several features that make it a better fit for Vicidial, but it uses more load to preform the same tasks and it does not have a 19 year track record of being rock solid stable.
- Changes to ConfBridge
One request we have gotten through the years with the MeetMe conference engine was to remove the "Bloop" sound that is heard by both the agents and the customer when the customer enters the conference. The only issue with doing this is it means the agent does not get an auditory alert when a customers channel enters their phone conference. Agent's have a bad habit of not paying attention to their screen. As such it is not really a good idea to have no alert when the customer enters the conference. With the changes being done to Vicidial to accommodate ConfBridge we felt that altering the ConfBridge code to allow a way to not play this incoming alter to the customer, while still playing it to the agent was a good idea. We added an option to user profile of the confbridge.conf configuration file in Asterisk called "hear_own_join_sound". When this is set to 'no' a channel entering a conference using their user profile will trigger the sound_join audio file to be played BEFORE the channel gets placed into the conference. When this option is set to 'yes' the channel is placed into the conference before the sound_join audio file is played. After quite a bit of back and forth with the Asterisk developers we were able to get this option merged into the official version of ConfBridge.
- Dialplan changes
The following extensions needed to be added to the Asterisk /etc/asterisk/extensions.conf dialplan to work with ConfBridge:
; --------------------------
; ConfBridge Extensions
; --------------------------
; use to send a agent channel into the conference
exten => _9600XXX,1,Answer()
exten => _9600XXX,n,Playback(sip-silence)
exten => _9600XXX,n,ConfBridge(${EXTEN},vici_agent_bridge,vici_customer_user)
exten => _9600XXX,n,Hangup()
; used to send an customer channel into the conference
exten => _29600XXX,1,Answer()
exten => _29600XXX,n,Playback(sip-silence)
exten => _29600XXX,n,ConfBridge(${EXTEN:1},vici_agent_bridge,vici_agent_user)
exten => _29600XXX,n,Hangup()
; used by an admin to enter the confernece
exten => _39600XXX,1,Answer()
exten => _39600XXX,n,Playback(sip-silence)
exten => _39600XXX,n,ConfBridge(${EXTEN:1},vici_agent_bridge,vici_admin_user)
exten => _39600XXX,n,Hangup()
; used to monitor a conference
exten => _49600XXX,1,Answer()
exten => _49600XXX,n,Playback(sip-silence)
exten => _49600XXX,n,ConfBridge(${EXTEN:1},vici_agent_bridge,vici_monitor_user)
exten => _49600XXX,n,Hangup()
; used to barge into a conference
exten => _59600XXX,1,Answer()
exten => _59600XXX,n,Playback(sip-silence)
exten => _59600XXX,n,ConfBridge(${EXTEN:1},vici_agent_bridge,vici_recording_user)
exten => _59600XXX,n,Hangup()
; used to record a conference
exten => _69600XXX,1,Answer()
exten => _69600XXX,n,Playback(sip-silence)
exten => _69600XXX,n,ConfBridge(${EXTEN:1},vici_agent_bridge,vici_barge_user)
exten => _69600XXX,n,Hangup()
; used to trigger DTMF tones in a conference
exten => _79600XXX,1,Answer()
exten => _79600XXX,n,Playback(sip-silence)
exten => _79600XXX,n,ConfBridge(${EXTEN:1},vici_agent_bridge,vici_dtmf_user)
exten => _79600XXX,n,Hangup()
; Used to play an audio file to a conference
exten => _89600XXX,1,Answer()
exten => _89600XXX,n,Playback(sip-silence)
exten => _89600XXX,n,ConfBridge(${EXTEN:1},vici_agent_bridge,vici_audio_user)
exten => _89600XXX,n,Hangup()
; Used to kick all channels from a conference
exten => _99600XXX,1,ConfKick(${EXTEN:1},all)
exten => _99600XXX,2,Hangup()
exten => _55559600XXX,1,ConfKick(${EXTEN:4},all)
exten => _55559600XXX,2,Hangup()
One key difference between how Vicidial handles MeetMe and ConfBridge conferences is the way various types of channels enter a conference. Each channel type now has its own conference user profile. Most noteably the customer's channel is placed into the conference with a different user profile than the agent. With MeetMe these two types of channel used the same extension to enter the conference. These seperations should allow for more advanced features to be added in the future.
- ConfBridge configuration
In the /etc/asterisk/confbridge.conf add:
#include "confbridge-vicidial.conf"
to the bottom of the file. There create the /etc/asterisk/confbridge-vicidial.conf file with the following contents:
; Bridge Profile for agent conferences
[vici_agent_bridge]
type=bridge
max_members=10
record_conference=no
internal_sample_rate=8000
mixing_interval=40
video_mode=none
sound_join=enter
sound_leave=leave
sound_has_joined=sip-silence
sound_has_left=sip-silence
sound_kicked=sip-silence
sound_muted=sip-silence
sound_unmuted=sip-silence
sound_only_person=confbridge-only-participant
sound_only_one=sip-silence
sound_there_are=sip-silence
sound_other_in_party=sip-silence
sound_begin=sip-silence
sound_wait_for_leader=sip-silence
sound_leader_has_left=sip-silence
sound_get_pin=sip-silence
sound_invalid_pin=sip-silence
sound_locked=sip-silence
sound_locked_now=sip-silence
sound_unlocked_now=sip-silence
sound_error_menu=sip-silence
sound_participants_muted=sip-silence
; User Profile for agent channels
[vici_agent_user]
type=user
admin=no
quiet=no
startmuted=no
marked=yes
dtmf_passthrough=yes
hearjoin=yes
dsp_drop_silence=yes
; User Profile for admin channels
[vici_admin_user]
type=user
admin=yes
quiet=no
startmuted=no
marked=yes
dtmf_passthrough=yes
dsp_drop_silence=yes
; User Profile for monitoring
[vici_monitor_user]
type=user
admin=no
quiet=no
startmuted=yes
marked=no
dtmf_passthrough=no
dsp_drop_silence=yes
; User Profile for barging
[vici_barge_user]
type=user
admin=no
quiet=no
startmuted=no
marked=no
dtmf_passthrough=yes
dsp_drop_silence=yes
; User Profile for customers channels
[vici_customer_user]
type=user
admin=no
quiet=no
startmuted=no
marked=yes
dtmf_passthrough=yes
hearjoin=no
dsp_drop_silence=yes
; User Profile for call recording channels
[vici_recording_user]
type=user
admin=no
quiet=yes
startmuted=yes
marked=no
dtmf_passthrough=no
dsp_drop_silence=yes
; User Profile for audio playback channels
[vici_audio_user]
type=user
admin=no
quiet=yes
startmuted=yes
marked=no
dtmf_passthrough=no
dsp_drop_silence=yes
; User Profile for triggering DTMF
[vici_dtmf_user]
type=user
admin=no
quiet=yes
startmuted=yes
marked=no
dtmf_passthrough=yes
dsp_drop_silence=yes
- Database changes
To accomodate the change to ConfBridge two fields were added to the "servers" table in Vicidial and another table was added. Here are the two fields added to the servers table:
NOTE: These have already been added to the standard VICIdial install and upgrade SQL files:
alter table servers add column `conf_engine` enum('MEETME','CONFBRIDGE') COLLATE utf8_unicode_ci DEFAULT 'MEETME';
alter table servers add column `conf_update_interval` smallint(6) NOT NULL DEFAULT 60;
The conf_engine field determines which conferencing engine a server is using. This changes the way calls route on this server as well as the way the agent interface logs an agent in on the server. The conf_update_interval determines how often the new AST_conf_update_screen.pl screen process checks both MeetMe and ConfBridge conferences for orphaned channels. This is the SQL for adding the new table:
NOTE: This have already been added to the standard VICIdial install and upgrade SQL files:
CREATE TABLE `vicidial_confbridges` (
`conf_exten` int(7) unsigned NOT NULL,
`server_ip` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`extension` varchar(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`leave_3way` enum('0','1') COLLATE utf8_unicode_ci DEFAULT '0',
`leave_3way_datetime` datetime DEFAULT NULL,
UNIQUE KEY `serverconf` (`server_ip`,`conf_exten`),
UNIQUE KEY `conf_exten` (`conf_exten`,`server_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
This table is currently the same as the vicidial_conferences table, but may be changed in the future to accomidate new features that can be added with ConfBridge. The following entries need to be inserted into the vicidial_confbridges table:
INSERT INTO `vicidial_confbridges` VALUES
(9600000,'10.10.10.17','','0',NULL),
(9600001,'10.10.10.17','','0',NULL),
(9600002,'10.10.10.17','','0',NULL),
(9600003,'10.10.10.17','','0',NULL),
(9600004,'10.10.10.17','','0',NULL),
(9600005,'10.10.10.17','','0',NULL),
(9600006,'10.10.10.17','','0',NULL),
(9600007,'10.10.10.17','','0',NULL),
(9600008,'10.10.10.17','','0',NULL),
(9600009,'10.10.10.17','','0',NULL),
(9600010,'10.10.10.17','','0',NULL),
(9600011,'10.10.10.17','','0',NULL),
(9600012,'10.10.10.17','','0',NULL),
(9600013,'10.10.10.17','','0',NULL),
(9600014,'10.10.10.17','','0',NULL),
(9600015,'10.10.10.17','','0',NULL),
(9600016,'10.10.10.17','','0',NULL),
(9600017,'10.10.10.17','','0',NULL),
(9600018,'10.10.10.17','','0',NULL),
(9600019,'10.10.10.17','','0',NULL),
(9600020,'10.10.10.17','','0',NULL),
(9600021,'10.10.10.17','','0',NULL),
(9600022,'10.10.10.17','','0',NULL),
(9600023,'10.10.10.17','','0',NULL),
(9600024,'10.10.10.17','','0',NULL),
(9600025,'10.10.10.17','','0',NULL),
(9600026,'10.10.10.17','','0',NULL),
(9600027,'10.10.10.17','','0',NULL),
(9600028,'10.10.10.17','','0',NULL),
(9600029,'10.10.10.17','','0',NULL),
(9600030,'10.10.10.17','','0',NULL),
(9600031,'10.10.10.17','','0',NULL),
(9600032,'10.10.10.17','','0',NULL),
(9600033,'10.10.10.17','','0',NULL),
(9600034,'10.10.10.17','','0',NULL),
(9600035,'10.10.10.17','','0',NULL),
(9600036,'10.10.10.17','','0',NULL),
(9600037,'10.10.10.17','','0',NULL),
(9600038,'10.10.10.17','','0',NULL),
(9600039,'10.10.10.17','','0',NULL),
(9600040,'10.10.10.17','','0',NULL),
(9600041,'10.10.10.17','','0',NULL),
(9600042,'10.10.10.17','','0',NULL),
(9600043,'10.10.10.17','','0',NULL),
(9600044,'10.10.10.17','','0',NULL),
(9600045,'10.10.10.17','','0',NULL),
(9600046,'10.10.10.17','','0',NULL),
(9600047,'10.10.10.17','','0',NULL),
(9600048,'10.10.10.17','','0',NULL),
(9600049,'10.10.10.17','','0',NULL),
(9600050,'10.10.10.17','','0',NULL),
(9600051,'10.10.10.17','','0',NULL),
(9600052,'10.10.10.17','','0',NULL),
(9600053,'10.10.10.17','','0',NULL),
(9600054,'10.10.10.17','','0',NULL),
(9600055,'10.10.10.17','','0',NULL),
(9600056,'10.10.10.17','','0',NULL),
(9600057,'10.10.10.17','','0',NULL),
(9600058,'10.10.10.17','','0',NULL),
(9600059,'10.10.10.17','','0',NULL),
(9600060,'10.10.10.17','','0',NULL),
(9600061,'10.10.10.17','','0',NULL),
(9600062,'10.10.10.17','','0',NULL),
(9600063,'10.10.10.17','','0',NULL),
(9600064,'10.10.10.17','','0',NULL),
(9600065,'10.10.10.17','','0',NULL),
(9600066,'10.10.10.17','','0',NULL),
(9600067,'10.10.10.17','','0',NULL),
(9600068,'10.10.10.17','','0',NULL),
(9600069,'10.10.10.17','','0',NULL),
(9600070,'10.10.10.17','','0',NULL),
(9600071,'10.10.10.17','','0',NULL),
(9600072,'10.10.10.17','','0',NULL),
(9600073,'10.10.10.17','','0',NULL),
(9600074,'10.10.10.17','','0',NULL),
(9600075,'10.10.10.17','','0',NULL),
(9600076,'10.10.10.17','','0',NULL),
(9600077,'10.10.10.17','','0',NULL),
(9600078,'10.10.10.17','','0',NULL),
(9600079,'10.10.10.17','','0',NULL),
(9600080,'10.10.10.17','','0',NULL),
(9600081,'10.10.10.17','','0',NULL),
(9600082,'10.10.10.17','','0',NULL),
(9600083,'10.10.10.17','','0',NULL),
(9600084,'10.10.10.17','','0',NULL),
(9600085,'10.10.10.17','','0',NULL),
(9600086,'10.10.10.17','','0',NULL),
(9600087,'10.10.10.17','','0',NULL),
(9600088,'10.10.10.17','','0',NULL),
(9600089,'10.10.10.17','','0',NULL),
(9600090,'10.10.10.17','','0',NULL),
(9600091,'10.10.10.17','','0',NULL),
(9600092,'10.10.10.17','','0',NULL),
(9600093,'10.10.10.17','','0',NULL),
(9600094,'10.10.10.17','','0',NULL),
(9600095,'10.10.10.17','','0',NULL),
(9600096,'10.10.10.17','','0',NULL),
(9600097,'10.10.10.17','','0',NULL),
(9600098,'10.10.10.17','','0',NULL),
(9600099,'10.10.10.17','','0',NULL),
(9600100,'10.10.10.17','','0',NULL),
(9600101,'10.10.10.17','','0',NULL),
(9600102,'10.10.10.17','','0',NULL),
(9600103,'10.10.10.17','','0',NULL),
(9600104,'10.10.10.17','','0',NULL),
(9600105,'10.10.10.17','','0',NULL),
(9600106,'10.10.10.17','','0',NULL),
(9600107,'10.10.10.17','','0',NULL),
(9600108,'10.10.10.17','','0',NULL),
(9600109,'10.10.10.17','','0',NULL),
(9600110,'10.10.10.17','','0',NULL),
(9600111,'10.10.10.17','','0',NULL),
(9600112,'10.10.10.17','','0',NULL),
(9600113,'10.10.10.17','','0',NULL),
(9600114,'10.10.10.17','','0',NULL),
(9600115,'10.10.10.17','','0',NULL),
(9600116,'10.10.10.17','','0',NULL),
(9600117,'10.10.10.17','','0',NULL),
(9600118,'10.10.10.17','','0',NULL),
(9600119,'10.10.10.17','','0',NULL),
(9600120,'10.10.10.17','','0',NULL),
(9600121,'10.10.10.17','','0',NULL),
(9600122,'10.10.10.17','','0',NULL),
(9600123,'10.10.10.17','','0',NULL),
(9600124,'10.10.10.17','','0',NULL),
(9600125,'10.10.10.17','','0',NULL),
(9600126,'10.10.10.17','','0',NULL),
(9600127,'10.10.10.17','','0',NULL),
(9600128,'10.10.10.17','','0',NULL),
(9600129,'10.10.10.17','','0',NULL),
(9600130,'10.10.10.17','','0',NULL),
(9600131,'10.10.10.17','','0',NULL),
(9600132,'10.10.10.17','','0',NULL),
(9600133,'10.10.10.17','','0',NULL),
(9600134,'10.10.10.17','','0',NULL),
(9600135,'10.10.10.17','','0',NULL),
(9600136,'10.10.10.17','','0',NULL),
(9600137,'10.10.10.17','','0',NULL),
(9600138,'10.10.10.17','','0',NULL),
(9600139,'10.10.10.17','','0',NULL),
(9600140,'10.10.10.17','','0',NULL),
(9600141,'10.10.10.17','','0',NULL),
(9600142,'10.10.10.17','','0',NULL),
(9600143,'10.10.10.17','','0',NULL),
(9600144,'10.10.10.17','','0',NULL),
(9600145,'10.10.10.17','','0',NULL),
(9600146,'10.10.10.17','','0',NULL),
(9600147,'10.10.10.17','','0',NULL),
(9600148,'10.10.10.17','','0',NULL),
(9600149,'10.10.10.17','','0',NULL),
(9600150,'10.10.10.17','','0',NULL),
(9600151,'10.10.10.17','','0',NULL),
(9600152,'10.10.10.17','','0',NULL),
(9600153,'10.10.10.17','','0',NULL),
(9600154,'10.10.10.17','','0',NULL),
(9600155,'10.10.10.17','','0',NULL),
(9600156,'10.10.10.17','','0',NULL),
(9600157,'10.10.10.17','','0',NULL),
(9600158,'10.10.10.17','','0',NULL),
(9600159,'10.10.10.17','','0',NULL),
(9600160,'10.10.10.17','','0',NULL),
(9600161,'10.10.10.17','','0',NULL),
(9600162,'10.10.10.17','','0',NULL),
(9600163,'10.10.10.17','','0',NULL),
(9600164,'10.10.10.17','','0',NULL),
(9600165,'10.10.10.17','','0',NULL),
(9600166,'10.10.10.17','','0',NULL),
(9600167,'10.10.10.17','','0',NULL),
(9600168,'10.10.10.17','','0',NULL),
(9600169,'10.10.10.17','','0',NULL),
(9600170,'10.10.10.17','','0',NULL),
(9600171,'10.10.10.17','','0',NULL),
(9600172,'10.10.10.17','','0',NULL),
(9600173,'10.10.10.17','','0',NULL),
(9600174,'10.10.10.17','','0',NULL),
(9600175,'10.10.10.17','','0',NULL),
(9600176,'10.10.10.17','','0',NULL),
(9600177,'10.10.10.17','','0',NULL),
(9600178,'10.10.10.17','','0',NULL),
(9600179,'10.10.10.17','','0',NULL),
(9600180,'10.10.10.17','','0',NULL),
(9600181,'10.10.10.17','','0',NULL),
(9600182,'10.10.10.17','','0',NULL),
(9600183,'10.10.10.17','','0',NULL),
(9600184,'10.10.10.17','','0',NULL),
(9600185,'10.10.10.17','','0',NULL),
(9600186,'10.10.10.17','','0',NULL),
(9600187,'10.10.10.17','','0',NULL),
(9600188,'10.10.10.17','','0',NULL),
(9600189,'10.10.10.17','','0',NULL),
(9600190,'10.10.10.17','','0',NULL),
(9600191,'10.10.10.17','','0',NULL),
(9600192,'10.10.10.17','','0',NULL),
(9600193,'10.10.10.17','','0',NULL),
(9600194,'10.10.10.17','','0',NULL),
(9600195,'10.10.10.17','','0',NULL),
(9600196,'10.10.10.17','','0',NULL),
(9600197,'10.10.10.17','','0',NULL),
(9600198,'10.10.10.17','','0',NULL),
(9600199,'10.10.10.17','','0',NULL),
(9600200,'10.10.10.17','','0',NULL),
(9600201,'10.10.10.17','','0',NULL),
(9600202,'10.10.10.17','','0',NULL),
(9600203,'10.10.10.17','','0',NULL),
(9600204,'10.10.10.17','','0',NULL),
(9600205,'10.10.10.17','','0',NULL),
(9600206,'10.10.10.17','','0',NULL),
(9600207,'10.10.10.17','','0',NULL),
(9600208,'10.10.10.17','','0',NULL),
(9600209,'10.10.10.17','','0',NULL),
(9600210,'10.10.10.17','','0',NULL),
(9600211,'10.10.10.17','','0',NULL),
(9600212,'10.10.10.17','','0',NULL),
(9600213,'10.10.10.17','','0',NULL),
(9600214,'10.10.10.17','','0',NULL),
(9600215,'10.10.10.17','','0',NULL),
(9600216,'10.10.10.17','','0',NULL),
(9600217,'10.10.10.17','','0',NULL),
(9600218,'10.10.10.17','','0',NULL),
(9600219,'10.10.10.17','','0',NULL),
(9600220,'10.10.10.17','','0',NULL),
(9600221,'10.10.10.17','','0',NULL),
(9600222,'10.10.10.17','','0',NULL),
(9600223,'10.10.10.17','','0',NULL),
(9600224,'10.10.10.17','','0',NULL),
(9600225,'10.10.10.17','','0',NULL),
(9600226,'10.10.10.17','','0',NULL),
(9600227,'10.10.10.17','','0',NULL),
(9600228,'10.10.10.17','','0',NULL),
(9600229,'10.10.10.17','','0',NULL),
(9600230,'10.10.10.17','','0',NULL),
(9600231,'10.10.10.17','','0',NULL),
(9600232,'10.10.10.17','','0',NULL),
(9600233,'10.10.10.17','','0',NULL),
(9600234,'10.10.10.17','','0',NULL),
(9600235,'10.10.10.17','','0',NULL),
(9600236,'10.10.10.17','','0',NULL),
(9600237,'10.10.10.17','','0',NULL),
(9600238,'10.10.10.17','','0',NULL),
(9600239,'10.10.10.17','','0',NULL),
(9600240,'10.10.10.17','','0',NULL),
(9600241,'10.10.10.17','','0',NULL),
(9600242,'10.10.10.17','','0',NULL),
(9600243,'10.10.10.17','','0',NULL),
(9600244,'10.10.10.17','','0',NULL),
(9600245,'10.10.10.17','','0',NULL),
(9600246,'10.10.10.17','','0',NULL),
(9600247,'10.10.10.17','','0',NULL),
(9600248,'10.10.10.17','','0',NULL),
(9600249,'10.10.10.17','','0',NULL),
(9600250,'10.10.10.17','','0',NULL),
(9600251,'10.10.10.17','','0',NULL),
(9600252,'10.10.10.17','','0',NULL),
(9600253,'10.10.10.17','','0',NULL),
(9600254,'10.10.10.17','','0',NULL),
(9600255,'10.10.10.17','','0',NULL),
(9600256,'10.10.10.17','','0',NULL),
(9600257,'10.10.10.17','','0',NULL),
(9600258,'10.10.10.17','','0',NULL),
(9600259,'10.10.10.17','','0',NULL),
(9600260,'10.10.10.17','','0',NULL),
(9600261,'10.10.10.17','','0',NULL),
(9600262,'10.10.10.17','','0',NULL),
(9600263,'10.10.10.17','','0',NULL),
(9600264,'10.10.10.17','','0',NULL),
(9600265,'10.10.10.17','','0',NULL),
(9600266,'10.10.10.17','','0',NULL),
(9600267,'10.10.10.17','','0',NULL),
(9600268,'10.10.10.17','','0',NULL),
(9600269,'10.10.10.17','','0',NULL),
(9600270,'10.10.10.17','','0',NULL),
(9600271,'10.10.10.17','','0',NULL),
(9600272,'10.10.10.17','','0',NULL),
(9600273,'10.10.10.17','','0',NULL),
(9600274,'10.10.10.17','','0',NULL),
(9600275,'10.10.10.17','','0',NULL),
(9600276,'10.10.10.17','','0',NULL),
(9600277,'10.10.10.17','','0',NULL),
(9600278,'10.10.10.17','','0',NULL),
(9600279,'10.10.10.17','','0',NULL),
(9600280,'10.10.10.17','','0',NULL),
(9600281,'10.10.10.17','','0',NULL),
(9600282,'10.10.10.17','','0',NULL),
(9600283,'10.10.10.17','','0',NULL),
(9600284,'10.10.10.17','','0',NULL),
(9600285,'10.10.10.17','','0',NULL),
(9600286,'10.10.10.17','','0',NULL),
(9600287,'10.10.10.17','','0',NULL),
(9600288,'10.10.10.17','','0',NULL),
(9600289,'10.10.10.17','','0',NULL),
(9600290,'10.10.10.17','','0',NULL),
(9600291,'10.10.10.17','','0',NULL),
(9600292,'10.10.10.17','','0',NULL),
(9600293,'10.10.10.17','','0',NULL),
(9600294,'10.10.10.17','','0',NULL),
(9600295,'10.10.10.17','','0',NULL),
(9600296,'10.10.10.17','','0',NULL),
(9600297,'10.10.10.17','','0',NULL),
(9600298,'10.10.10.17','','0',NULL),
(9600299,'10.10.10.17','','0',NULL);
and their IP addresses adjusted for the server that is being setup to use ConfBridge.
- Code changes:
Included in the "extras/ConfBridge/" directory of the svn/trunk codebase are several new/patched files that need to be applied to the servers on your system for ConfBridge compatibility with VICIdial. They can be applied by going into the directory with the file to be patched in it and then running commands like the following:
vici-dev1:/srv/www/htdocs/agc/ # patch -p0 < vicidial.php.diff
patching file vicidial.php
NOTE: The "AST_conf_update_screen.pl" script is a new perl script, not a patch file, so it just needs to be copied to the proper directory and given 'r' + 'x' file permissions.
Here is the list of files for specific default directories:
Dialers:
/usr/share/astguiclient -
- ADMIN_keepalive_ALL.pl.diff
- ADMIN_update_server_ip.pl.diff
- AST_DB_optimize.pl.diff
- AST_reset_mysql_vars.pl.diff
- AST_conf_update_screen.pl
Webservers:
/srv/www/htdocs/agc -
- vicidial.php.diff
- vdc_db_query.php.diff
- manager_send.php.diff
+125
View File
@@ -0,0 +1,125 @@
--- manager_send.php.old 2022-08-26 16:03:28.232951728 -0400
+++ manager_send.php 2022-08-23 15:55:47.677934909 -0400
@@ -1763,6 +1763,7 @@
$row=''; $rowx='';
$channel_liveX=1;
$channel_liveY=1;
+ $conf_table = 'vicidial_conferences';
if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($session_id)<3) or ( ( (strlen($extrachannel)<3) or (strlen($exten)<1) ) and (!preg_match("/NEXTAVAILABLE/",$exten)) ) )
{
$channel_liveX=0;
@@ -1790,19 +1791,26 @@
{
if (preg_match("/NEXTAVAILABLE/",$exten))
{
- $stmtA="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';";
+ # figure out which table to look in
+ $stmtA="SELECT conf_engine FROM servers WHERE server_ip='$server_ip';";
+ if ($format=='debug') {echo "\n<!-- $stmtA -->";}
+ $rslt=mysql_to_mysqli($stmtA, $link);
+ $row=mysqli_fetch_row($rslt);
+ if ($row[0] == "CONFBRIDGE") { $conf_table = 'vicidial_confbridges'; }
+
+ $stmtA="SELECT count(*) FROM $conf_table where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmtA -->";}
$rslt=mysql_to_mysqli($stmtA, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtA,'02029',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
if ($row[0] > 1)
{
- $stmtB="UPDATE vicidial_conferences set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;";
+ $stmtB="UPDATE $conf_table set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmtB -->";}
$rslt=mysql_to_mysqli($stmtB, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtB,'02030',$user,$server_ip,$session_name,$one_mysql_log);}
- $stmtC="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';";
+ $stmtC="SELECT conf_exten from $conf_table where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmtC -->";}
$rslt=mysql_to_mysqli($stmtC, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtC,'02031',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -1814,12 +1822,12 @@
$extension = "$extension$user";
}
- $stmtD="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;";
+ $stmtD="UPDATE $conf_table set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmtD -->";}
$rslt=mysql_to_mysqli($stmtD, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtD,'02032',$user,$server_ip,$session_name,$one_mysql_log);}
- $stmtE="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';";
+ $stmtE="UPDATE $conf_table set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';";
if ($format=='debug') {echo "\n<!-- $stmtE -->";}
$rslt=mysql_to_mysqli($stmtE, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmtE,'02033',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -1857,7 +1865,7 @@
else
{
$channel_liveX=0;
- echo _QXZ("Cannot find empty vicidial_conference on %1s, Redirect command not inserted",0,'',$server_ip)."\n|$stmt|";
+ echo _QXZ("Cannot find empty $conf_table on %1s, Redirect command not inserted",0,'',$server_ip)."\n|$stmt|";
if (preg_match("/SECOND|FIRST|DEBUG/",$filename)) {$DBout .= "Cannot find empty conference on $server_ip";}
$stage .= "|ERROR $server_ip|";
}
@@ -1989,6 +1997,7 @@
$row=''; $rowx='';
$channel_liveX=1;
$channel_liveY=1;
+ $conf_table = 'vicidial_conferences';
if ( (strlen($channel)<3) or (strlen($queryCID)<15) or (strlen($ext_context)<1) or (strlen($ext_priority)<1) or (strlen($session_id)<3) or ( ( (strlen($extrachannel)<3) or (strlen($exten)<1) ) and (!preg_match("/NEXTAVAILABLE/",$exten)) ) )
{
$channel_liveX=0;
@@ -2018,31 +2027,38 @@
{
if (preg_match("/NEXTAVAILABLE/",$exten))
{
- $stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';";
+ # figure out which table to look in
+ $stmtA="SELECT conf_engine FROM servers WHERE server_ip='$server_ip';";
+ if ($format=='debug') {echo "\n<!-- $stmtA -->";}
+ $rslt=mysql_to_mysqli($stmtA, $link);
+ $row=mysqli_fetch_row($rslt);
+ if ($row[0] == "CONFBRIDGE") { $conf_table = 'vicidial_confbridges'; }
+
+ $stmt="SELECT count(*) FROM $conf_table where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02045',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
if ($row[0] > 1)
{
- $stmt="UPDATE vicidial_conferences set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;";
+ $stmt="UPDATE $conf_table set extension='$protocol/$extension$NOWnum', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) and conf_exten != '$session_id' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02046',$user,$server_ip,$session_name,$one_mysql_log);}
- $stmt="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';";
+ $stmt="SELECT conf_exten from $conf_table where server_ip='$server_ip' and extension='$protocol/$extension$NOWnum' and conf_exten != '$session_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02047',$user,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$exten = $row[0];
- $stmt="UPDATE vicidial_conferences set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;";
+ $stmt="UPDATE $conf_table set extension='$protocol/$extension' where server_ip='$server_ip' and conf_exten='$exten' limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02048',$user,$server_ip,$session_name,$one_mysql_log);}
- $stmt="UPDATE vicidial_conferences set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';";
+ $stmt="UPDATE $conf_table set leave_3way='1', leave_3way_datetime='$NOW_TIME', extension='3WAY_$user' where server_ip='$server_ip' and conf_exten='$session_id';";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'02049',$user,$server_ip,$session_name,$one_mysql_log);}
@@ -2076,7 +2092,7 @@
else
{
$channel_liveX=0;
- echo "Cannot find empty vicidial_conference on $server_ip, Redirect command not inserted\n|$stmt|";
+ echo "Cannot find empty $conf_table on $server_ip, Redirect command not inserted\n|$stmt|";
if (preg_match("/SECOND|FIRST|DEBUG/",$filename)) {$DBout .= "Cannot find empty conference on $server_ip";}
$stage .= "|ERROR $server_ip|";
}
+20
View File
@@ -0,0 +1,20 @@
--- vdc_db_query.php.old 2022-08-26 16:05:04.444619207 -0400
+++ vdc_db_query.php 2022-08-26 16:05:25.996544730 -0400
@@ -16297,8 +16297,15 @@
if ($no_delete_sessions < 1)
{
- ##### Remove the reservation on the vicidial_conferences meetme room
- $stmt="UPDATE vicidial_conferences set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';";
+ ##### Figure out which conference table to use
+ $conf_table = 'vicidial_conferences';
+ $stmt="SELECT conf_engine FROM servers where server_ip='$server_ip';";
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $row=mysqli_fetch_row($rslt);
+ if ( $row[0] == 'CONFBRIDGE' ) { $conf_table = 'vicidial_confbridges'; }
+
+ ##### Remove the reservation on the vicidial_conferences or vicidial_confbridges room
+ $stmt="UPDATE $conf_table set extension='' where server_ip='$server_ip' and conf_exten='$conf_exten';";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00129',$user,$server_ip,$session_name,$one_mysql_log);}
+108
View File
@@ -0,0 +1,108 @@
--- vicidial.php.old 2022-08-26 16:06:54.916237481 -0400
+++ vicidial.php 2022-08-26 16:06:39.472290841 -0400
@@ -3446,6 +3446,15 @@
}
else
{$rowx[0]='0.0.0.0';}
+
+ ##### figure out which table to look for conferences in
+ $stmt="SELECT conf_engine from servers where server_ip = '$rowx[0]';";
+ if ($DB) {echo "|$stmt|\n";}
+ $rslt=mysql_to_mysqli($stmt, $link);
+ $row=mysqli_fetch_row($rslt);
+ $conf_engine = $row[3];
+ $conf_table = "vicidial_conferences";
+ if ( $conf_engine == "CONFBRIDGE" ) { $conf_table = "vicidial_confbridges"; }
### get number of agents logged in to each server
$stmt="SELECT count(*) from vicidial_live_agents where server_ip = '$rowx[0]' and extension NOT LIKE \"R%\";";
@@ -3461,7 +3470,7 @@
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01023',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$rowy=mysqli_fetch_row($rslt);
- $stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$rowx[0]' and ((extension='') or (extension is null));";
+ $stmt="SELECT count(*) FROM $conf_table where server_ip='$rowx[0]' and ((extension='') or (extension is null));";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01085',$VD_login,$server_ip,$session_name,$one_mysql_log);}
@@ -3674,14 +3683,15 @@
$local_gmt = ($local_gmt + $isdst);
}
- $stmt="SELECT asterisk_version,web_socket_url,external_web_socket_url from servers where server_ip='$server_ip';";
+ $stmt="SELECT asterisk_version,web_socket_url,external_web_socket_url,conf_engine from servers where server_ip='$server_ip';";
if ($DB) {echo "|$stmt|\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01028',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$asterisk_version = $row[0];
$web_socket_url = $row[1];
- $external_web_socket_url = $row[2];
+ $external_web_socket_url = $row[2];
+ $conf_engine = $row[3];
if ( ($use_external_server_ip=='Y') and (strlen($external_web_socket_url) > 5) )
{$web_socket_url = $external_web_socket_url;}
$major_version = explode('.',$asterisk_version);
@@ -3804,8 +3814,12 @@
if ( ( ($campaign_allow_inbound == 'Y') and ($dial_method != 'MANUAL') ) || ($campaign_leads_to_call > 0) || (preg_match('/Y/',$no_hopper_leads_logins)) )
{
+ ##### figure out which table to look for conferences in
+ $conf_table = "vicidial_conferences";
+ if ( $conf_engine == "CONFBRIDGE" ) { $conf_table = "vicidial_confbridges"; }
+
##### check to see if the user has a conf extension already, this happens if they previously exited uncleanly
- $stmt="SELECT conf_exten FROM vicidial_conferences where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;";
+ $stmt="SELECT conf_exten FROM $conf_table where extension='$SIP_user' and server_ip = '$server_ip' LIMIT 1;";
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01032',$VD_login,$server_ip,$session_name,$one_mysql_log);}
if ($DB) {echo "$stmt\n";}
@@ -3818,30 +3832,30 @@
$i++;
}
if ($prev_login_ct > 0)
- {echo "<!-- USING PREVIOUS MEETME ROOM - $session_id - $NOW_TIME - $SIP_user -->\n";}
+ {echo "<!-- USING PREVIOUS $conf_engine ROOM - $session_id - $NOW_TIME - $SIP_user -->\n";}
else
{
- ##### grab the next available vicidial_conference room and reserve it
- $stmt="SELECT count(*) FROM vicidial_conferences where server_ip='$server_ip' and ((extension='') or (extension is null));";
+ ##### grab the next available conference room and reserve it
+ $stmt="SELECT count(*) FROM $conf_table where server_ip='$server_ip' and ((extension='') or (extension is null));";
if ($DB) {echo "$stmt\n";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01033',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
if ($row[0] > 0)
{
- $stmt="UPDATE vicidial_conferences set extension='$SIP_user', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;";
+ $stmt="UPDATE $conf_table set extension='$SIP_user', leave_3way='0' where server_ip='$server_ip' and ((extension='') or (extension is null)) limit 1;";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01034',$VD_login,$server_ip,$session_name,$one_mysql_log);}
- $stmt="SELECT conf_exten from vicidial_conferences where server_ip='$server_ip' and ( (extension='$SIP_user') or (extension='$VD_login') );";
+ $stmt="SELECT conf_exten from $conf_table where server_ip='$server_ip' and ( (extension='$SIP_user') or (extension='$VD_login') );";
if ($format=='debug') {echo "\n<!-- $stmt -->";}
$rslt=mysql_to_mysqli($stmt, $link);
if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01035',$VD_login,$server_ip,$session_name,$one_mysql_log);}
$row=mysqli_fetch_row($rslt);
$session_id = $row[0];
}
- echo "<!-- USING NEW MEETME ROOM - $session_id - $NOW_TIME - $SIP_user -->\n";
+ echo "<!-- USING NEW $conf_engine ROOM - $session_id - $NOW_TIME - $SIP_user -->\n";
}
### mark leads that were not dispositioned during previous calls as ERI
@@ -3984,8 +3998,10 @@
if ($on_hook_agent == 'Y')
{$TEMP_SIP_user_DiaL = 'Local/8300@default';}
### insert a NEW record to the vicidial_manager table to be processed
+ $session_prepend = '';
+ if ( $conf_engine == 'CONFBRIDGE' ) { $session_prepend = 2; }
$agent_login_data="||$NOW_TIME|NEW|N|$server_ip||Originate|$SIqueryCID|Channel: $SIP_user_DiaL|Context: $login_context|Exten: $session_id|Priority: 1|Callerid: \"$SIqueryCID\" <$campaign_cid>|||||";
- $agent_login_stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $TEMP_SIP_user_DiaL','Context: $login_context','Exten: $session_id','Priority: 1','Callerid: \"$SIqueryCID\" <$campaign_cid>','','','','','');";
+ $agent_login_stmt="INSERT INTO vicidial_manager values('','','$NOW_TIME','NEW','N','$server_ip','','Originate','$SIqueryCID','Channel: $TEMP_SIP_user_DiaL','Context: $login_context','Exten: $session_prepend$session_id','Priority: 1','Callerid: \"$SIqueryCID\" <$campaign_cid>','','','','','');";
if ( ($is_webphone != 'Y') and ($is_webphone != 'Y_API_LAUNCH') )
{
if ($DB) {echo "$agent_login_stmt\n";}
+14 -2
View File
@@ -166,7 +166,9 @@ gather_asterisk_output ENUM('Y','N') default 'N',
web_socket_url VARCHAR(255) default '',
conf_qualify ENUM('Y','N') default 'Y',
routing_prefix VARCHAR(10) default '13',
external_web_socket_url VARCHAR(255) default ''
external_web_socket_url VARCHAR(255) default '',
conf_engine ENUM('MEETME','CONFBRIDGE') COLLATE utf8_unicode_ci DEFAULT 'MEETME',
conf_update_interval SMALLINT(6) NOT NULL DEFAULT '60'
) ENGINE=MyISAM;
CREATE UNIQUE INDEX server_id on servers (server_id);
@@ -4740,6 +4742,16 @@ index (caller_code),
index (call_date)
) ENGINE=MyISAM;
CREATE TABLE `vicidial_confbridges` (
`conf_exten` INT(7) UNSIGNED NOT NULL,
`server_ip` VARCHAR(15) COLLATE utf8_unicode_ci NOT NULL,
`extension` VARCHAR(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`leave_3way` ENUM('0','1') COLLATE utf8_unicode_ci DEFAULT '0',
`leave_3way_datetime` DATETIME DEFAULT NULL,
UNIQUE KEY `serverconf` (`server_ip`,`conf_exten`),
UNIQUE KEY `conf_exten` (`conf_exten`,`server_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE vicidial_email_list MODIFY message text character set utf8;
@@ -5089,4 +5101,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1663',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1664',db_schema_update_date=NOW(),reload_timestamp=NOW();
+15
View File
@@ -1948,3 +1948,18 @@ ALTER TABLE system_settings ADD user_codes_admin ENUM('0','1','2','3','4','5','6
INSERT INTO vicidial_settings_containers(container_id,container_notes,container_type,user_group,container_entry) VALUES ('USER_CODES_SYSTEM','User Codes List','OTHER','---ALL---','');
UPDATE system_settings SET db_schema_version='1663',db_schema_update_date=NOW() where db_schema_version < 1663;
ALTER TABLE servers ADD `conf_engine` ENUM('MEETME','CONFBRIDGE') COLLATE utf8_unicode_ci DEFAULT 'MEETME';
ALTER TABLE servers ADD `conf_update_interval` SMALLINT(6) NOT NULL DEFAULT 60;
CREATE TABLE `vicidial_confbridges` (
`conf_exten` INT(7) UNSIGNED NOT NULL,
`server_ip` VARCHAR(15) COLLATE utf8_unicode_ci NOT NULL,
`extension` VARCHAR(100) COLLATE utf8_unicode_ci DEFAULT NULL,
`leave_3way` ENUM('0','1') COLLATE utf8_unicode_ci DEFAULT '0',
`leave_3way_datetime` DATETIME DEFAULT NULL,
UNIQUE KEY `serverconf` (`server_ip`,`conf_exten`),
UNIQUE KEY `conf_exten` (`conf_exten`,`server_ip`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
UPDATE system_settings SET db_schema_version='1664',db_schema_update_date=NOW() where db_schema_version < 1664;