From 43b8e284b48e18583e5656054c6754eb9823dc27 Mon Sep 17 00:00:00 2001 From: mattf Date: Mon, 20 Nov 2006 18:22:23 +0000 Subject: [PATCH] continuing work on AST_VDauto_dial_FILL.pl added balance fill process doc git-svn-id: svn://192.168.202.10@396 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl | 133 ++++++++++++++++---- agc_2-X/trunk/docs/BALANCE_FILL_PROCESS.txt | 33 +++++ 2 files changed, 140 insertions(+), 26 deletions(-) create mode 100644 agc_2-X/trunk/docs/BALANCE_FILL_PROCESS.txt diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl b/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl index 9494a0c8..bfe33b1c 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl @@ -180,6 +180,8 @@ while($one_day_interval > 0) ############################################################################### @DBfill_campaign=@MT; @DBfill_shortage=@MT; + @DBfill_tally=@MT; + @DBfill_needed=@MT; @DBlive_campaign=@MT; @DBlive_conf_exten=@MT; @DBlive_status=@MT; @@ -286,7 +288,12 @@ while($one_day_interval > 0) $rec_count++; } $sthA->finish(); - $event_string="DB_balance_fill: $DB_balance_fill VAC_balance_fill: $VAC_balance_fill\n"; + $event_string=" CAMPAIGN: $DBfill_campaign[$camp_CIPct]\n"; + $event_string.="DB_balance_fill: $DB_balance_fill VAC_balance_fill: $VAC_balance_fill\n"; + + $DBfill_needed[$camp_CIPct] = ($DBfill_shortage[$camp_CIPct] - $VAC_balance_fill); + $event_string.="Additional Balance Calls Needed For This Campaign: $DBfill_needed[$camp_CIPct]\n"; + ##### Get a listing of the servers in the campaign that have shortages of trunks $full_servers='|'; @@ -327,20 +334,20 @@ while($one_day_interval > 0) ################################################################################## if ($AVAIL_balance_servers > 0) { + $event_string="Balance Servers available: $AVAIL_balance_servers"; + &event_logger; + $DB_camp_servers=0; @DB_camp_server_server_ip=@MT; @DB_camp_server_max_vicidial_trunks=@MT; @DB_camp_server_balance_trunks_offlimits=@MT; @DB_camp_server_dedicated_trunks=@MT; @DB_camp_server_trunk_restriction=@MT; - $DB_NONcamp_servers=0; - @DB_NONcamp_server_server_ip=@MT; - @DB_NONcamp_server_max_vicidial_trunks=@MT; - @DB_NONcamp_server_balance_trunks_offlimits=@MT; @DB_NONcamp_server_dedicated_trunks=@MT; - @DB_NONcamp_server_trunk_restriction=@MT; + @DB_camp_server_available=@MT; + @DB_camp_server_trunks_to_dial=@MT; ##### Get the trunk settings for the campaign across all servers - $stmtA = "SELECT servers.server_ip,max_vicidial_trunks,balance_trunks_offlimits,dedicated_trunks,trunk_restriction FROM servers,vicidial_server_trunks where vicidial_balance_active = 'Y' and servers.server_ip NOT IN($full_serversSQL) and campaign_id='$DBfill_campaign[$camp_CIPct]' and servers.server_ip=vicidial_server_trunks.server_ip order by servers.server_ip;"; + $stmtA = "SELECT server_ip,max_vicidial_trunks,balance_trunks_offlimits FROM servers where vicidial_balance_active = 'Y' and server_ip NOT IN($full_serversSQL) order by server_ip;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; $sthArows=$sthA->rows; @@ -351,34 +358,74 @@ while($one_day_interval > 0) $DB_camp_server_server_ip[$DB_camp_servers] = "$aryA[0]"; $DB_camp_server_max_vicidial_trunks[$DB_camp_servers] = "$aryA[1]"; $DB_camp_server_balance_trunks_offlimits[$DB_camp_servers] = "$aryA[2]"; - $DB_camp_server_dedicated_trunks[$DB_camp_servers] = "$aryA[3]"; - $DB_camp_server_trunk_restriction[$DB_camp_servers] = "$aryA[4]"; $DB_camp_servers++; $rec_count++; } $sthA->finish(); - ##### Get the trunk settings for other campaigns across all servers - $stmtA = "SELECT servers.server_ip,max_vicidial_trunks,balance_trunks_offlimits,dedicated_trunks,trunk_restriction FROM servers,vicidial_server_trunks where vicidial_balance_active = 'Y' and servers.server_ip NOT IN($full_serversSQL) and campaign_id NOT IN('$DBfill_campaign[$camp_CIPct]') and servers.server_ip=vicidial_server_trunks.server_ip order by servers.server_ip;"; - $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) + + ################################################################################## + ##### LOOP THROUGH SERVERS, CALCULATE TRUNKS FOR EACH FOR THIS CAMPAIGN + ################################################################################## + $server_CIPct = 0; + foreach(@DB_camp_server_server_ip) { - @aryA = $sthA->fetchrow_array; - $DB_NONcamp_server_server_ip[$DB_NONcamp_servers] = "$aryA[0]"; - $DB_NONcamp_server_max_vicidial_trunks[$DB_NONcamp_servers] = "$aryA[1]"; - $DB_NONcamp_server_balance_trunks_offlimits[$DB_NONcamp_servers] = "$aryA[2]"; - $DB_NONcamp_server_dedicated_trunks[$DB_NONcamp_servers] = "$aryA[3]"; - $DB_NONcamp_server_trunk_restriction[$DB_NONcamp_servers] = "$aryA[4]"; - $DB_NONcamp_servers++; - $rec_count++; - } - $sthA->finish(); + $DB_camp_server_dedicated_trunks[$server_CIPct]=0; + $DB_camp_server_trunk_restriction[$server_CIPct]=0; + $DB_NONcamp_server_dedicated_trunks[$server_CIPct]=0; + ##### Get the campaign-specific trunk settings for the campaign on this server + $stmtA = "SELECT dedicated_trunks,trunk_restriction FROM vicidial_server_trunks where server_ip='$DB_camp_server_server_ip[$server_CIPct]' and campaign_id='$DBfill_campaign[$camp_CIPct]';"; + $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; + $DB_camp_server_dedicated_trunks[$server_CIPct] = "$aryA[0]"; + $DB_camp_server_trunk_restriction[$server_CIPct] = "$aryA[1]"; + $rec_count++; + } + $sthA->finish(); + ##### Get the campaign-specific dedicated trunks count for other campaigns on this server + $stmtA = "SELECT sum(dedicated_trunks) FROM vicidial_server_trunks where server_ip='$DB_camp_server_server_ip[$server_CIPct]' and campaign_id NOT IN('$DBfill_campaign[$camp_CIPct]');"; + $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; + $DB_NONcamp_server_dedicated_trunks[$server_CIPct] = "$aryA[0]"; + $rec_count++; + } + $sthA->finish(); + if ($DB_camp_server_trunk_restriction[$server_CIPct] =~ /MAXIMUM_LIMIT/) + { + $DB_camp_server_available[$server_CIPct] = $DB_camp_server_dedicated_trunks[$server_CIPct]; + } + else + { + $DB_camp_server_available[$server_CIPct] = ( ($DB_camp_server_max_vicidial_trunks[$server_CIPct] - $DB_camp_server_balance_trunks_offlimits[$server_CIPct]) - $DB_NONcamp_server_dedicated_trunks[$server_CIPct]); + } + $temp_tally = ($DBfill_needed[$camp_CIPct] - $DBfill_tally[$camp_CIPct]); + if ($DB_camp_server_available[$server_CIPct] >= $temp_tally) + { + $DB_camp_server_trunks_to_dial[$server_CIPct] = $temp_tally; + $DBfill_tally[$camp_CIPct] = ($DBfill_tally[$camp_CIPct] + $temp_tally); + } + else + { + $DB_camp_server_trunks_to_dial[$server_CIPct] = $DB_camp_server_available[$server_CIPct]; + $DBfill_tally[$camp_CIPct] = ($DBfill_tally[$camp_CIPct] + $DB_camp_server_trunks_to_dial[$server_CIPct]); + } + + $event_string=" Server: $DB_camp_server_server_ip[$server_CIPct] AVAIL: $DB_camp_server_available[$server_CIPct] DIAL: $DB_camp_server_trunks_to_dial[$server_CIPct]"; + $event_string.=" Campaign Dial Fill tally: $DBfill_tally[$camp_CIPct]/$DBfill_needed[$camp_CIPct]"; + &event_logger; # so far we have a check of balance servers, a check of shortage servers and we begin traversing the campaigns array exit; @@ -389,6 +436,40 @@ exit; + + + + + + + + + + $server_CIPct++; + } + + } + else + { + $event_string.="No Balance Servers available that do not have a shortage"; + &event_logger; + } + + $camp_CIPct++; + } + + } + else + { + $event_string.="No Balance Servers available or No Shortages"; + &event_logger; + } + + + + + + $DBIPserver_trunks_limit[$camp_CIPct] = ''; $DBIPserver_trunks_other[$camp_CIPct] = 0; $DBIPserver_trunks_allowed[$camp_CIPct] = $max_vicidial_trunks; diff --git a/agc_2-X/trunk/docs/BALANCE_FILL_PROCESS.txt b/agc_2-X/trunk/docs/BALANCE_FILL_PROCESS.txt new file mode 100644 index 00000000..5961950f --- /dev/null +++ b/agc_2-X/trunk/docs/BALANCE_FILL_PROCESS.txt @@ -0,0 +1,33 @@ +VICIDIAL Dialing-out Balance FILL proces flow 2006-11-20 + +** FULL VICIDIAL BALANCE DIALING FUNCTIONALITY WAS ADDED IN THE 2.0.2 RELEASE ** + +This will outline the process I have thought through in my head for a process to allow for dialing-out only servers and for lines on one VICIDIAL server to be utilized when another dialing server does not have enough lines to meet it's dial level for the number of agents that are on the server. + + + +MySQL changes: +ALTER TABLE vicidial_auto_calls MODIFY call_type ENUM('IN','OUT','OUTBALANCE') default 'OUT'; +Added OUTBALANCE to keep track of the calls that were originated by the Balance FILL process. + + + +Changes to existing AST_VDauto_dial.pl script: +Only one notable change for CLOSER campaigns to look for OUTBALANCE in addition to OUT calls in vicidial_auto_calls when dialing BLENDED on CLOSER campaigns. + + + +Process Flow of the AST_VDauto_dial_FILL.pl script: +- Check if there are any servers with vicidial_balance_active=Y and no trunk shortage + - Get a count of the shortages and what campaigns they are on + - Start looping through the campaigns with trunk shortages + - Get a count of the DB value and current balance_trunk_fill + - Get list of servers with trunk shortfall + - Get a count of the servers that have no shortfall and allow balance dialing + - Get dialing variable values for servers with balance available and no shortfall + - Loop through these servers + - Calculate the available trunks for this campaign per server + - Calculate the number of trunks to dial for this server for this campaign + + +