diff --git a/agc_2-X/trunk/bin/ADMIN_keepalive_AST_VDadapt.pl b/agc_2-X/trunk/bin/ADMIN_keepalive_AST_VDadapt.pl new file mode 100644 index 00000000..756de89a --- /dev/null +++ b/agc_2-X/trunk/bin/ADMIN_keepalive_AST_VDadapt.pl @@ -0,0 +1,138 @@ +#!/usr/bin/perl +# +# ADMIN_keepalive_AST_VDadapt.pl version 0.1 +# +# designed to keep the AST_update processes aline and check every minute +# +# Copyright (C) 2006 Matt Florell LICENSE: GPLv2 +# +# +# 60828-1151 - first build +# + +$DB=0; # Debug flag +$MT[0]=''; $MT[1]=''; +@psline=@MT; + +### 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 [-t] = test\n [-debug] = verbose debug messages\n[-debugX] = Extra-verbose debug messages\n\n"; + } + else + { + if ($args =~ /-debug/i) + { + $DB=1; # Debug flag + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /-t/i) + { + $TEST=1; + $T=1; + } + } +} +else +{ +# print "no command line options set\n"; +} +### 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 = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ( ($line =~ /^PATHhome/) && ($CLIhome < 1) ) + {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + $i++; + } + +$REGhome = $PATHhome; +$REGhome =~ s/\//\\\//gi; + +#@psoutput = `ps -f -C AST_update --no-headers`; +#@psoutput = `ps -f -C AST_updat* --no-headers`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; + +$running_VDAD = 0; + +$i=0; +foreach (@psoutput) +{ + chomp($psoutput[$i]); +if ($DBX) {print "$i|$psoutput[$i]| \n";} +@psline = split(/\/usr\/bin\/perl /,$psoutput[$i]); + +if ($psline[1] =~ /$REGhome\/AST_VDadapt\.pl/) + { + $running_VDAD++; + if ($DB) {print "VDAD RUNNING: |$psline[1]|\n";} + } + +$i++; +} + + +if (!$running_VDAD) +{ +# print "double check that VDAD is not running\n"; + + sleep(4); + +#@psoutput = `ps -f -C AST_update --no-headers`; +#@psoutput = `ps -f -C AST_updat* --no-headers`; +#@psoutput = `/bin/ps -f --no-headers -A`; +@psoutput = `/bin/ps -o "%p %a" --no-headers -A`; +$i=0; +foreach (@psoutput2) + { + chomp($psoutput2[$i]); + if ($DBX) {print "$i|$psoutput[$i]| \n";} + @psline = split(/\/usr\/bin\/perl /,$psoutput2[$i]); + + if ($psline[1] =~ /$REGhome\/AST_VDadapt\.pl/) + { + $running_VDAD++; + if ($DB) {print "VDAD RUNNING: |$psline[1]|\n";} + } + + $i++; + } + +if (!$running_VDAD) + { + if ($DB) {print "starting AST_VDadapt...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTVDadapt $PATHhome/AST_VDadapt.pl`; + } +} + + + + + if ($DB) {print "DONE\n";} + +exit; diff --git a/agc_2-X/trunk/bin/AST_VDadapt.pl b/agc_2-X/trunk/bin/AST_VDadapt.pl index 5ed28c6f..08b06562 100644 --- a/agc_2-X/trunk/bin/AST_VDadapt.pl +++ b/agc_2-X/trunk/bin/AST_VDadapt.pl @@ -12,18 +12,55 @@ # 60826-0857 - added loop and CLI flag options # 60827-0035 - separate Drop calculation and target dial level calculation into different subroutines # - alter code so that DROP percentages would calculate only about once a minute no matter he loop delay - -# TODO -# - write ADMIN_keepalive script for this script to keep it running continuously -# - add field for target dial_level difference, -1 would target one agent waiting, +1 would target 1 customer waiting -# - change latest_target_gmt to latest_target_time which would be a 4 digit server time number to reduce confusion -# +# 60828-1149 - add field for target dial_level difference, -1 would target one agent waiting, +1 would target 1 customer waiting +# # constants $DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate lots of lines of output per minute $US='__'; $MT[0]=''; +$drop_count_updater=0; +$VCScalls_today=0; +$VCSdrops_today=0; +$VCSdrops_today_pct=0; +$VCScalls_hour=0; +$VCSdrops_hour=0; +$VCSdrops_hour_pct=0; +$VCScalls_halfhour=0; +$VCSdrops_halfhour=0; +$VCSdrops_halfhour_pct=0; +$VCScalls_five=0; +$VCSdrops_five=0; +$VCSdrops_five_pct=0; +$VCScalls_one=0; +$VCSdrops_one=0; +$VCSdrops_one_pct=0; +$total_agents=0; +$ready_agents=0; +$waiting_calls=0; +$stat_it=15; +$ready_diff_total=0; +$waiting_diff_total=0; +$total_agents_total=0; +$ready_diff_avg=0; +$waiting_diff_avg=0; +$total_agents_avg=0; +$stat_differential=0; +$diff_ratio_updater=0; +$VCSINCALL=0; +$VCSREADY=0; +$VCSCLOSER=0; +$VCSPAUSED=0; +$VCSagents=0; +$VCSagents_calc=0; +$VCSagents_active=0; +$diff_ratio_updater=0; +$stat_count=1; + +# set to 61 initially so that a baseline drop count is pulled +$drop_count_updater=61; + $secT = time(); &get_time_now; @@ -44,84 +81,95 @@ if (length($ARGV[0])>1) else { if ($args =~ /--campaign=/i) # CLI defined campaign - { - @CLIvarARY = split(/--campaign=/,$args); - @CLIvarARX = split(/ /,$CLIvarARY[1]); - if (length($CLIvarARX[0])>2) { - $CLIcampaign = $CLIvarARX[0]; - $CLIcampaign =~ s/\/$| |\r|\n|\t//gi; + @CLIvarARY = split(/--campaign=/,$args); + @CLIvarARX = split(/ /,$CLIvarARY[1]); + if (length($CLIvarARX[0])>2) + { + $CLIcampaign = $CLIvarARX[0]; + $CLIcampaign =~ s/\/$| |\r|\n|\t//gi; + } + else + {$CLIcampaign = '';} + @CLIvarARY=@MT; @CLIvarARY=@MT; } else {$CLIcampaign = '';} - @CLIvarARY=@MT; @CLIvarARY=@MT; - } if ($args =~ /--level=/i) # CLI defined level - { - @CLIvarARY = split(/--level=/,$args); - @CLIvarARX = split(/ /,$CLIvarARY[1]); - if (length($CLIvarARX[0])>2) { - $CLIlevel = $CLIvarARX[0]; - $CLIlevel =~ s/\/$| |\r|\n|\t//gi; - $CLIlevel =~ s/\D//gi; + @CLIvarARY = split(/--level=/,$args); + @CLIvarARX = split(/ /,$CLIvarARY[1]); + if (length($CLIvarARX[0])>2) + { + $CLIlevel = $CLIvarARX[0]; + $CLIlevel =~ s/\/$| |\r|\n|\t//gi; + $CLIlevel =~ s/\D//gi; + } + else + {$CLIlevel = '';} + @CLIvarARY=@MT; @CLIvarARY=@MT; } else {$CLIlevel = '';} - @CLIvarARY=@MT; @CLIvarARY=@MT; - } if ($args =~ /--loops=/i) # CLI defined loops - { - @CLIvarARY = split(/--loops=/,$args); - @CLIvarARX = split(/ /,$CLIvarARY[1]); - if (length($CLIvarARX[0])>2) { - $CLIloops = $CLIvarARX[0]; - $CLIloops =~ s/\/$| |\r|\n|\t//gi; - $CLIloops =~ s/\D//gi; + @CLIvarARY = split(/--loops=/,$args); + @CLIvarARX = split(/ /,$CLIvarARY[1]); + if (length($CLIvarARX[0])>2) + { + $CLIloops = $CLIvarARX[0]; + $CLIloops =~ s/\/$| |\r|\n|\t//gi; + $CLIloops =~ s/\D//gi; + } + else + {$CLIloops = '1000000';} + @CLIvarARY=@MT; @CLIvarARY=@MT; } else {$CLIloops = '1000000';} - @CLIvarARY=@MT; @CLIvarARY=@MT; - } if ($args =~ /--delay=/i) # CLI defined delay - { - @CLIvarARY = split(/--delay=/,$args); - @CLIvarARX = split(/ /,$CLIvarARY[1]); - if (length($CLIvarARX[0])>2) { - $CLIdelay = $CLIvarARX[0]; - $CLIdelay =~ s/\/$| |\r|\n|\t//gi; - $CLIdelay =~ s/\D//gi; + @CLIvarARY = split(/--delay=/,$args); + @CLIvarARX = split(/ /,$CLIvarARY[1]); + if (length($CLIvarARX[0])>2) + { + $CLIdelay = $CLIvarARX[0]; + $CLIdelay =~ s/\/$| |\r|\n|\t//gi; + $CLIdelay =~ s/\D//gi; + } + else + {$CLIdelay = '1';} + @CLIvarARY=@MT; @CLIvarARY=@MT; } else {$CLIdelay = '1';} - @CLIvarARY=@MT; @CLIvarARY=@MT; - } if ($args =~ /--debug/i) - { - $DB=1; - print "\n----- DEBUG -----\n\n"; - } + { + $DB=1; + print "\n----- DEBUG -----\n\n"; + } if ($args =~ /--debugX/i) - { - $DBX=1; - print "\n----- SUPER DEBUG -----\n\n"; - } + { + $DBX=1; + print "\n"; + print "----- SUPER DEBUG -----\n"; + print "VARS-\n"; + print "CLIcampaign- $CLIcampaign\n"; + print "CLIlevel- $CLIlevel\n"; + print "CLIloops- $CLIloops\n"; + print "CLIdelay- $CLIdelay\n"; + print "\n"; + } if ($args =~ /-force/i) - { - $force_test=1; - print "\n----- FORCE TESTING -----\n\n"; - } + { + $force_test=1; + print "\n----- FORCE TESTING -----\n\n"; + } if ($args =~ /-t/i) - { - $T=1; $TEST=1; - print "\n-----TESTING -----\n\n"; - } - if ($args =~ /--wipe-hopper-clean/i) - { - $wipe_hopper_clean=1; - } + { + $T=1; $TEST=1; + print "\n-----TESTING -----\n\n"; + } } } @@ -170,15 +218,11 @@ use DBI; $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") or die "Couldn't connect to database: " . DBI->errstr; +if ($DBX) {print "CONNECTED TO DATABASE: $VARDB_server|$VARDB_database\n";} $master_loop=0; -$diff_ratio_updater=0; -$drop_count_updater=0; - -$stat_count=1; - ### Start master loop ### while ($master_loop<$CLIloops) { @@ -220,7 +264,7 @@ while ($master_loop<$CLIloops) if ($min < 10) {$min = "0$min";} if ($sec < 10) {$sec = "0$sec";} - if ($DB) {print "TIME DEBUG: $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} +# if ($DB) {print "TIME DEBUG: $master_loop $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";} @campaign_id=@MT; @@ -258,13 +302,14 @@ while ($sthArows > $rec_count) $available_only_ratio_tally[$rec_count] = $aryA[47]; $adaptive_dropped_percentage[$rec_count] = $aryA[48]; $adaptive_maximum_level[$rec_count] = $aryA[49]; - $adaptive_latest_target_gmt[$rec_count] = $aryA[50]; + $adaptive_latest_server_time[$rec_count] = $aryA[50]; $adaptive_intensity[$rec_count] = $aryA[51]; + $adaptive_dl_diff_target[$rec_count] = $aryA[52]; $rec_count++; } $sthA->finish(); -if ($DB) {print "CAMPAIGNS TO PROCESSES ADAPT FOR: $rec_count|$#campaign_id\n";} +if ($DB) {print "$now_date CAMPAIGNS TO PROCESSES ADAPT FOR: $rec_count|$#campaign_id IT: $master_loop\n";} ##### LOOP THROUGH EACH CAMPAIGN AND PROCESS THE HOPPER ##### @@ -282,12 +327,13 @@ foreach(@campaign_id) { @aryA = $sthA->fetchrow_array; $hopper_ready_count = $aryA[0]; - if ($DB) {print "\n $campaign_id[$i] hopper READY count: $hopper_ready_count\n";} - if ($DBX) {print " |$stmtA|\n";} + if ($DB) {print " $campaign_id[$i] hopper READY count: $hopper_ready_count";} +# if ($DBX) {print " |$stmtA|\n";} $rec_count++; } $sthA->finish(); $event_string = "|$campaign_id[$i]|$hopper_level[$i]|$hopper_ready_count|$local_call_time[$i]||"; + if ($DBX) {print "$i $event_string\n";} &event_logger; ##### IF THERE ARE NO LEADS IN THE HOPPER FOR THE CAMPAIGN WE DO NOT WANT TO ADJUST THE DIAL_LEVEL @@ -303,19 +349,25 @@ foreach(@campaign_id) { &count_agents_lines; } - - ### Update Drop counter every 60 seconds - if ($drop_count_updater>=60) + else { - &calculate_drops; + if ($DB) {print " CLOSER CAMPAIGN\n";} } - ### Calculate and update Dial level every 15 seconds - if ($diff_ratio_updater>=15) + if ($total_agents_avg > 0) { - &calculate_dial_level; - } + ### Update Drop counter every 60 seconds + if ($drop_count_updater>=60) + { + &calculate_drops; + } + ### Calculate and update Dial level every 15 seconds + if ($diff_ratio_updater>=15) + { + &calculate_dial_level; + } + } } $i++; } @@ -344,6 +396,10 @@ exit; + + +### SUBROUTINES ############################################################### + sub event_logger { if ($SYSLOG) @@ -435,6 +491,14 @@ sub count_agents_lines $total_agents=0; $ready_agents=0; $waiting_calls=0; +$stat_it=15; +$ready_diff_total=0; +$waiting_diff_total=0; +$total_agents_total=0; +$ready_diff_avg=0; +$waiting_diff_avg=0; +$total_agents_avg=0; +$stat_differential=0; $stmtA = "SELECT count(*),status from vicidial_live_agents where campaign_id='$campaign_id[$i]' and last_update_time > '$VDL_one' group by status;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -469,14 +533,6 @@ $stat_ready_agents[$i][$stat_count] = $ready_agents; $stat_waiting_calls[$i][$stat_count] = $waiting_calls; $stat_total_agents[$i][$stat_count] = $total_agents; -$stat_it=15; -$ready_diff_total=0; -$waiting_diff_total=0; -$total_agents_total=0; -$ready_diff_avg=0; -$waiting_diff_avg=0; -$total_agents_avg=0; -$stat_differential=0; if ($stat_count < 15) { $stat_it = $stat_count; @@ -495,6 +551,7 @@ while($it < $stat_it) $waiting_diff_total = ($waiting_diff_total + $stat_waiting_calls[$i][$it_ary]); $total_agents_total = ($total_agents_total + $stat_total_agents[$i][$it_ary]); # $event_string="$stat_count $it_ary $stat_total_agents[$i][$it_ary]|$stat_ready_agents[$i][$it_ary]|$stat_waiting_calls[$i][$it_ary]"; +# if ($DB) {print " $event_string\n";} # &event_logger; $it++; } @@ -508,6 +565,9 @@ if ($total_agents_total > 0) $stat_differential = ($ready_diff_avg - $waiting_diff_avg); $event_string="CAMPAIGN DIFFERENTIAL: $total_agents_avg $stat_differential ($ready_diff_avg - $waiting_diff_avg)"; +if ($DBX) {print "$campaign_id[$i]|$event_string\n";} +if ($DB) {print " $event_string\n";} + &event_logger; # $stmtA = "UPDATE vicidial_campaign_stats SET differential_onemin='$stat_differential', agents_average_onemin='$total_agents_avg' where campaign_id='$DBIPcampaign[$i]';"; @@ -703,6 +763,7 @@ if ($VCScalls_five > 0) } $sthA->finish(); } +if ($DBX) {print "$campaign_id[$i]|$VCSdrops_five_pct|$VCSdrops_today_pct\n";} } @@ -770,173 +831,17 @@ else $differential_onemin = $stat_differential; } -##### BEGIN calculate what gmt_offset_now values are within the allowed local_call_time setting ### -$last_target_hour=0; -$g=0; -$p='13'; -$GMT_gmt[0] = ''; -$GMT_hour[0] = ''; -$GMT_day[0] = ''; - if ($DBX) {print "\n |GMT-DAY-HOUR| ";} -while ($p > -13) - { - $pzone = ($GMT_now + ($p * 3600)); - ($psec,$pmin,$phour,$pmday,$pmon,$pyear,$pday,$pyday,$pisdst) = localtime($pzone); - $phour=($phour * 100); - $tz = sprintf("%.2f", $p); - $GMT_gmt[$g] = "$tz"; - $GMT_day[$g] = "$pday"; - $GMT_hour[$g] = ($phour + $pmin); - $p = ($p - 0.25); - if ($DBX) {print "|$GMT_gmt[$g]-$GMT_day[$g]-$GMT_hour[$g]|";} - $g++; - } - if ($DBX) {print "\n";} - -$stmtA = "SELECT * FROM vicidial_call_times where call_time_id='$local_call_time[$i]';"; - if ($DBX) {print " |$stmtA|\n";} -$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; - $Gct_default_start = "$aryA[3]"; - $Gct_default_stop = "$aryA[4]"; - $Gct_sunday_start = "$aryA[5]"; - $Gct_sunday_stop = "$aryA[6]"; - $Gct_monday_start = "$aryA[7]"; - $Gct_monday_stop = "$aryA[8]"; - $Gct_tuesday_start = "$aryA[9]"; - $Gct_tuesday_stop = "$aryA[10]"; - $Gct_wednesday_start = "$aryA[11]"; - $Gct_wednesday_stop = "$aryA[12]"; - $Gct_thursday_start = "$aryA[13]"; - $Gct_thursday_stop = "$aryA[14]"; - $Gct_friday_start = "$aryA[15]"; - $Gct_friday_stop = "$aryA[16]"; - $Gct_saturday_start = "$aryA[17]"; - $Gct_saturday_stop = "$aryA[18]"; - $Gct_state_call_times = "$aryA[19]"; - $rec_count++; - } -$sthA->finish(); - -$ct_states = ''; -$ct_state_gmt_SQL = ''; -$del_state_gmt_SQL = ''; -$ct_srs=0; -$b=0; -$r=0; -$default_gmt=''; -$del_default_gmt=''; -while($r < $g) - { - if ($GMT_day[$r]==0) #### Sunday local time - { - if (($Gct_sunday_start==0) and ($Gct_sunday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_sunday_start) and ($GMT_hour[$r]<$Gct_sunday_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - } - if ($GMT_day[$r]==1) #### Monday local time - { - if (($Gct_monday_start==0) and ($Gct_monday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_monday_start) and ($GMT_hour[$r]<$Gct_monday_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - } - if ($GMT_day[$r]==2) #### Tuesday local time - { - if (($Gct_tuesday_start==0) and ($Gct_tuesday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_tuesday_start) and ($GMT_hour[$r]<$Gct_tuesday_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - } - if ($GMT_day[$r]==3) #### Wednesday local time - { - if (($Gct_wednesday_start==0) and ($Gct_wednesday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_wednesday_start) and ($GMT_hour[$r]<$Gct_wednesday_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - } - if ($GMT_day[$r]==4) #### Thursday local time - { - if (($Gct_thursday_start==0) and ($Gct_thursday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_thursday_start) and ($GMT_hour[$r]<$Gct_thursday_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - } - if ($GMT_day[$r]==5) #### Friday local time - { - if (($Gct_friday_start==0) and ($Gct_friday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_friday_start) and ($GMT_hour[$r]<$Gct_friday_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - } - if ($GMT_day[$r]==6) #### Saturday local time - { - if (($Gct_saturday_start==0) and ($Gct_saturday_stop==0)) - { - if ( ($GMT_hour[$r]>=$Gct_default_start) and ($GMT_hour[$r]<$Gct_default_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - else - { - if ( ($GMT_hour[$r]>=$Gct_saturday_start) and ($GMT_hour[$r]<$Gct_saturday_stop) ) - {if ($GMT_hour[$r] > $last_target_hour) {$last_target_hour=$GMT_hour[$r];}} - } - } - $r++; - } -##### END calculate what gmt_offset_now values are within the allowed local_call_time setting ### - ## UPDATE STATS FOR CAMPAIGN $stmtA = "UPDATE vicidial_campaign_stats SET calls_today='$VCScalls_today',drops_today='$VCSdrops_today',drops_today_pct='$VCSdrops_today_pct',calls_hour='$VCScalls_hour',drops_hour='$VCSdrops_hour',drops_hour_pct='$VCSdrops_hour_pct',calls_halfhour='$VCScalls_halfhour',drops_halfhour='$VCSdrops_halfhour',drops_halfhour_pct='$VCSdrops_halfhour_pct',calls_fivemin='$VCScalls_five',drops_fivemin='$VCSdrops_five',drops_fivemin_pct='$VCSdrops_five_pct',calls_onemin='$VCScalls_one',drops_onemin='$VCSdrops_one',drops_onemin_pct='$VCSdrops_one_pct' where campaign_id='$campaign_id[$i]';"; $affected_rows = $dbhA->do($stmtA); +if ($DBX) {print "$campaign_id[$i]|$stmtA|\n";} if ( ($dial_method[$i] =~ /ADAPT_HARD_LIMIT|ADAPT_AVERAGE|ADAPT_TAPERED/) || ($force_test>0) ) { # Calculate the optimal dial_level differential for the past minute - $differential_mul = ($differential_onemin / $agents_average_onemin); + $differential_target = ($differential_onemin + $adaptive_dl_diff_target[$i]); + $differential_mul = ($differential_target / $agents_average_onemin); $differential_pct_raw = ($differential_mul * 100); $differential_pct = sprintf("%.2f", $differential_pct_raw); @@ -961,10 +866,8 @@ if ( ($dial_method[$i] =~ /ADAPT_HARD_LIMIT|ADAPT_AVERAGE|ADAPT_TAPERED/) || ($f $intensity_dial_level = sprintf("%.3f", $intensity_dial_level); # Calculate last timezone target for ADAPT_TAPERED - $last_hour_diff_gmt = ($LOCAL_GMT_OFF - $adaptive_latest_target_gmt[$i]); - $last_hour_diff = ($last_hour_diff_gmt * 100); - $last_target_hour_final = ($last_target_hour + $last_hour_diff); - if ($last_target_hour_final>2400) {$last_target_hour_final=2400;} + $last_target_hour_final = $adaptive_latest_server_time[$i]; +# if ($last_target_hour_final>2400) {$last_target_hour_final=2400;} $tapered_hours_left = ($last_target_hour_final - $current_hourmin); if ($tapered_hours_left > 1000) {$tapered_rate = 1;} @@ -974,20 +877,19 @@ if ( ($dial_method[$i] =~ /ADAPT_HARD_LIMIT|ADAPT_AVERAGE|ADAPT_TAPERED/) || ($f $adaptive_string = "\n"; $adaptive_string .= "CAMPAIGN: $campaign_id[$i]\n"; $adaptive_string .= "SETTINGS-\n"; - $adaptive_string .= " DIAL_LEVEL: $auto_dial_level[$i]\n"; - $adaptive_string .= " DIALMETHOD: $dial_method[$i]\n"; - $adaptive_string .= " AVAIL ONLY: $available_only_ratio_tally[$i]\n"; - $adaptive_string .= " DROP PCNT: $adaptive_dropped_percentage[$i]\n"; - $adaptive_string .= " MAX LEVEL: $adaptive_maximum_level[$i]\n"; - $adaptive_string .= " SERVER GMT: $LOCAL_GMT_OFF - $current_hourmin\n"; - $adaptive_string .= " LATESTHOUR: $last_target_hour\n"; - $adaptive_string .= " LATEST GMT: $adaptive_latest_target_gmt[$i]\n"; - $adaptive_string .= " LATETARGET: $last_target_hour_final ($tapered_hours_left left|$tapered_rate)\n"; - $adaptive_string .= " INTENSITY: $adaptive_intensity[$i]\n"; + $adaptive_string .= " DIAL LEVEL: $auto_dial_level[$i]\n"; + $adaptive_string .= " DIAL METHOD: $dial_method[$i]\n"; + $adaptive_string .= " AVAIL ONLY: $available_only_ratio_tally[$i]\n"; + $adaptive_string .= " DROP PERCENT: $adaptive_dropped_percentage[$i]\n"; + $adaptive_string .= " MAX LEVEL: $adaptive_maximum_level[$i]\n"; + $adaptive_string .= " SERVER TIME: $current_hourmin\n"; + $adaptive_string .= " LATE TARGET: $last_target_hour_final ($tapered_hours_left left|$tapered_rate)\n"; + $adaptive_string .= " INTENSITY: $adaptive_intensity[$i]\n"; + $adaptive_string .= " DLDIFF TARGET: $adaptive_dl_diff_target[$i]\n"; $adaptive_string .= "CURRENT STATS-\n"; $adaptive_string .= " AVG AGENTS: $agents_average_onemin\n"; $adaptive_string .= " AGENTS: $VCSagents ACTIVE: $VCSagents_active CALC: $VCSagents_calc INCALL: $VCSINCALL READY: $VCSREADY\n"; - $adaptive_string .= " DL DIFFERENTIAL: $differential_onemin\n"; + $adaptive_string .= " DL DIFFERENTIAL: $differential_target = ($differential_onemin + $adaptive_dl_diff_target[$i])\n"; $adaptive_string .= "DIAL LEVEL SUGGESTION-\n"; $adaptive_string .= " PERCENT DIFF: $differential_pct\n"; $adaptive_string .= " SUGGEST DL: $suggested_dial_level = ($auto_dial_level[$i] * ($differential_mul + 1) )\n"; diff --git a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql index 77afd788..35a93d6f 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -479,8 +479,9 @@ dial_method ENUM('MANUAL','RATIO','ADAPT_HARD_LIMIT','ADAPT_TAPERED','ADAPT_AVER available_only_ratio_tally ENUM('Y','N') default 'N', adaptive_dropped_percentage SMALLINT(3) default '3', adaptive_maximum_level VARCHAR(6) default '3.0', -adaptive_latest_target_gmt VARCHAR(6) default '-7', -adaptive_intensity VARCHAR(6) default '0' +adaptive_latest_server_time VARCHAR(4) default '2100', +adaptive_intensity VARCHAR(6) default '0', +adaptive_dl_diff_target SMALLINT(3) default '0' ); CREATE TABLE vicidial_lists ( diff --git a/agc_2-X/trunk/extras/upgrade_2.0.1.sql b/agc_2-X/trunk/extras/upgrade_2.0.1.sql index c2713d01..f6209fe3 100644 --- a/agc_2-X/trunk/extras/upgrade_2.0.1.sql +++ b/agc_2-X/trunk/extras/upgrade_2.0.1.sql @@ -22,8 +22,9 @@ ALTER TABLE vicidial_campaigns ADD dial_method ENUM('MANUAL','RATIO','ADAPT_HARD ALTER TABLE vicidial_campaigns ADD available_only_ratio_tally ENUM('Y','N') default 'N'; ALTER TABLE vicidial_campaigns ADD adaptive_dropped_percentage SMALLINT(3) default '3'; ALTER TABLE vicidial_campaigns ADD adaptive_maximum_level VARCHAR(6) default '3.0'; -ALTER TABLE vicidial_campaigns ADD adaptive_latest_target_gmt VARCHAR(6) default '-7'; +ALTER TABLE vicidial_campaigns ADD adaptive_latest_server_time VARCHAR(4) default '2100'; ALTER TABLE vicidial_campaigns ADD adaptive_intensity VARCHAR(6) default '0'; +ALTER TABLE vicidial_campaigns ADD adaptive_dl_diff_target SMALLINT(3) default '0'; ALTER TABLE vicidial_campaign_stats ADD differential_onemin VARCHAR(20) default '0'; ALTER TABLE vicidial_campaign_stats ADD agents_average_onemin VARCHAR(20) default '0'; diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt index 0143b810..402308ad 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.txt @@ -11,8 +11,9 @@ Dial Method -<\/B> This field is the way to define how dialing is to take place. Available Only Tally -<\/B> This field if set to Y will leave out INCALL and QUEUE status agents when calculating the number of calls to dial when not in MANUAL dial mode. Default is N Drop Percentage Limit -<\/B> This field is where you set the limit of the percentage of dropped calls you would like while using an adaptive-predictive dial method, not MANUAL or RATIO Maximum Adapt Dial Level -<\/B> This field is where you set the limit of the limit to the numbr of lines you would like dialed per agent while using an adaptive-predictive dial method, not MANUAL or RATIO. This number can be higher than the Auto Dial Level if your hardware will support it. Value must be a positive number greater than one and can have decimal places Default 3.0 -Latest Target Timezone -<\/B> This field is only used by the ADAPT_TAPERED dial method. You should select the current GMT offset value or timezone of the latest region that you will be calling. This allows the Tapered algorithm to decide how aggressively to dial by how long you have until you will be finished calling. NOTE- If you are calling in the USA and you have a very small amount of leads in Alaska or Hawaii but many leads in Pacific time zone, you should choose the pacific time zone for this field for the ADAPT_TAPERED dial method to work properly +Latest Server Time -<\/B> This field is only used by the ADAPT_TAPERED dial method. You should enter in the hour and minute that you will stop calling on this campaign, 2100 would mean that you will stop dialing this campaign at 9PM server time. This allows the Tapered algorithm to decide how aggressively to dial by how long you have until you will be finished calling Adapt Intensity Modifier -<\/B> This field is used to adjust the predictive intensity either higher or lower. The higher a positive number you select, the greater the dialer will increase the call pacing when it goes up and the slower the dialer will decrease the call pacing when it goes down. The lower the negative number you select here, the slower the dialer will increase the call pacing and the faster the dialer will lower the call pacing when it goes down. Default is 0. This field is not used by the MANUAL or RATIO dial methods +Dial Level Difference Target -<\/B> This field is used to define whether you want to target having a specific number of agents waiting for calls or calls waiting for agents. For example if you would always like to have on average one agent free to take calls immediately you would set this to -1, if you would like to target always having one call on hold waiting for an agent you would set this to 1. Default is 0. This field is not used by the MANUAL or RATIO dial methods System Performance Server Logs @@ -24,8 +25,9 @@ Dial Method Available Only Tally Drop Percentage Limit Maximum Adapt Dial Level -Latest Target Timezone +Latest Server Time Adapt Intensity Modifier +Dial Level Difference Target ############################################################ CLIENT diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 68b9ed18..dfb888d8 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -286,10 +286,13 @@ if (isset($_GET["available_only_ratio_tally"])) {$available_only_ratio_tally=$ elseif (isset($_POST["available_only_ratio_tally"])){$available_only_ratio_tally=$_POST["available_only_ratio_tally"];} if (isset($_GET["dial_method"])) {$dial_method=$_GET["dial_method"];} elseif (isset($_POST["dial_method"])) {$dial_method=$_POST["dial_method"];} -if (isset($_GET["adaptive_latest_target_gmt"])) {$adaptive_latest_target_gmt=$_GET["adaptive_latest_target_gmt"];} - elseif (isset($_POST["adaptive_latest_target_gmt"])){$adaptive_latest_target_gmt=$_POST["adaptive_latest_target_gmt"];} +if (isset($_GET["adaptive_latest_server_time"])) {$adaptive_latest_server_time=$_GET["adaptive_latest_server_time"];} + elseif (isset($_POST["adaptive_latest_server_time"])){$adaptive_latest_server_time=$_POST["adaptive_latest_server_time"];} if (isset($_GET["adaptive_intensity"])) {$adaptive_intensity=$_GET["adaptive_intensity"];} elseif (isset($_POST["adaptive_intensity"])) {$adaptive_intensity=$_POST["adaptive_intensity"];} +if (isset($_GET["adaptive_dl_diff_target"])) {$adaptive_dl_diff_target=$_GET["adaptive_dl_diff_target"];} + elseif (isset($_POST["adaptive_dl_diff_target"])) {$adaptive_dl_diff_target=$_POST["adaptive_dl_diff_target"];} + if (isset($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -360,6 +363,7 @@ $hotkey = ereg_replace("[^0-9]","",$hotkey); $list_id = ereg_replace("[^0-9]","",$list_id); $allcalls_delay = ereg_replace("[^0-9]","",$allcalls_delay); $adaptive_dropped_percentage = ereg_replace("[^0-9]","",$adaptive_dropped_percentage); +$adaptive_latest_server_time = ereg_replace("[^0-9]","",$adaptive_latest_server_time); ### Y or N ONLY ### $active = ereg_replace("[^NY]","",$active); @@ -448,8 +452,8 @@ $lead_filter_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$lead_filter_comm $campaign_rec_filename = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$campaign_rec_filename); $call_time_name = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_name); $call_time_comments = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$call_time_comments); -$adaptive_latest_target_gmt = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$adaptive_latest_target_gmt); $adaptive_intensity = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$adaptive_intensity); +$adaptive_dl_diff_target = ereg_replace("[^ \.\,-\_0-9a-zA-Z]","",$adaptive_dl_diff_target); ### remove semi-colons ### $lead_filter_sql = ereg_replace(";","",$lead_filter_sql); @@ -528,12 +532,14 @@ $lead_filter_sql = ereg_replace(";","",$lead_filter_sql); # 60823-1154 - added fields for adaptive dialing # 60824-1326 - added adaptive_latest_target_gmt for ADAPT_TAPERED dial method # 60825-1205 - added adaptive_intensity for ADAPT_ dial methods +# 60828-1019 - changed adaptive_latest_target_gmt to adaptive_latest_server_time +# 60828-1115 - added adaptive_dl_diff_target and changed intensity dropdown # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 8 to access this page the first time -$version = '2.0.63'; -$build = '60825-1205'; +$version = '2.0.65'; +$build = '60828-1115'; $STARTtime = date("U"); @@ -1136,15 +1142,20 @@ echo "
Maximum Adapt Dial Level - This field is where you set the limit of the limit to the numbr of lines you would like dialed per agent while using an adaptive-predictive dial method, not MANUAL or RATIO. This number can be higher than the Auto Dial Level if your hardware will support it. Value must be a positive number greater than one and can have decimal places Default 3.0.
- +
-Latest Target Timezone - This field is only used by the ADAPT_TAPERED dial method. You should select the current GMT offset value or timezone of the latest region that you will be calling. This allows the Tapered algorithm to decide how aggressively to dial by how long you have until you will be finished calling. NOTE- If you are calling in the USA and you have a very small amount of leads in Alaska or Hawaii but many leads in Pacific time zone, you should choose the pacific time zone for this field for the ADAPT_TAPERED dial method to work properly. +Latest Server Time - This field is only used by the ADAPT_TAPERED dial method. You should enter in the hour and minute that you will stop calling on this campaign, 2100 would mean that you will stop dialing this campaign at 9PM server time. This allows the Tapered algorithm to decide how aggressively to dial by how long you have until you will be finished calling.

Adapt Intensity Modifier - This field is used to adjust the predictive intensity either higher or lower. The higher a positive number you select, the greater the dialer will increase the call pacing when it goes up and the slower the dialer will decrease the call pacing when it goes down. The lower the negative number you select here, the slower the dialer will increase the call pacing and the faster the dialer will lower the call pacing when it goes down. Default is 0. This field is not used by the MANUAL or RATIO dial methods. +
+
+
+Dial Level Difference Target - This field is used to define whether you want to target having a specific number of agents waiting for calls or calls waiting for agents. For example if you would always like to have on average one agent free to take calls immediately you would set this to -1, if you would like to target always having one call on hold waiting for an agent you would set this to 1. Default is 0. This field is not used by the MANUAL or RATIO dial methods. +

@@ -2909,7 +2920,7 @@ if ($ADD==41) } } } - $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_target_gmt='$adaptive_latest_target_gmt',adaptive_intensity='$adaptive_intensity' where campaign_id='$campaign_id';"; + $stmtA="UPDATE vicidial_campaigns set campaign_name='$campaign_name',active='$active',dial_status_a='$dial_status_a',dial_status_b='$dial_status_b',dial_status_c='$dial_status_c',dial_status_d='$dial_status_d',dial_status_e='$dial_status_e',lead_order='$lead_order',allow_closers='$allow_closers',hopper_level='$hopper_level', $adlSQL next_agent_call='$next_agent_call', local_call_time='$local_call_time', voicemail_ext='$voicemail_ext', dial_timeout='$dial_timeout', dial_prefix='$dial_prefix', campaign_cid='$campaign_cid', campaign_vdad_exten='$campaign_vdad_exten', web_form_address='" . mysql_real_escape_string($web_form_address) . "', park_ext='$park_ext', park_file_name='$park_file_name', campaign_rec_exten='$campaign_rec_exten', campaign_recording='$campaign_recording', campaign_rec_filename='$campaign_rec_filename', campaign_script='$script_id', get_call_launch='$get_call_launch', am_message_exten='$am_message_exten', amd_send_to_vmx='$amd_send_to_vmx', xferconf_a_dtmf='$xferconf_a_dtmf',xferconf_a_number='$xferconf_a_number', xferconf_b_dtmf='$xferconf_b_dtmf',xferconf_b_number='$xferconf_b_number',lead_filter_id='$lead_filter_id',alt_number_dialing='$alt_number_dialing',scheduled_callbacks='$scheduled_callbacks',safe_harbor_message='$safe_harbor_message',drop_call_seconds='$drop_call_seconds',safe_harbor_exten='$safe_harbor_exten',wrapup_seconds='$wrapup_seconds',wrapup_message='$wrapup_message',closer_campaigns='$groups_value',use_internal_dnc='$use_internal_dnc',allcalls_delay='$allcalls_delay',omit_phone_code='$omit_phone_code',dial_method='$dial_method',available_only_ratio_tally='$available_only_ratio_tally',adaptive_dropped_percentage='$adaptive_dropped_percentage',adaptive_maximum_level='$adaptive_maximum_level',adaptive_latest_server_time='$adaptive_latest_server_time',adaptive_intensity='$adaptive_intensity',adaptive_dl_diff_target='$adaptive_dl_diff_target' where campaign_id='$campaign_id';"; $rslt=mysql_query($stmtA, $link); if ($reset_hopper == 'Y') @@ -4339,8 +4350,9 @@ echo "\n"; -echo "\n"; +echo "\n"; echo "\n"; +echo " $NWB#vicidial_campaigns-adaptive_intensity$NWE\n"; + + + +echo "\n"; + echo "\n"; @@ -4855,10 +4892,16 @@ echo "\n"; +echo " $NWB#vicidial_campaigns-adaptive_intensity$NWE\n"; echo "\n";
\n"; $available_only_ratio_tally = $row[47]; $adaptive_dropped_percentage = $row[48]; $adaptive_maximum_level = $row[49]; - $adaptive_latest_target_gmt = $row[50]; + $adaptive_latest_server_time = $row[50]; $adaptive_intensity = $row[51]; + $adaptive_dl_diff_target = $row[52]; echo "
MODIFY A CAMPAIGNS RECORD: $row[0] - Basic View"; echo " | Detail View | "; @@ -4437,16 +4449,41 @@ echo "% $NWB#vici echo "
Maximum Adapt Dial Level: number only $NWB#vicidial_campaigns-adaptive_maximum_level$NWE
Latest Target Timezone: (MUST Adjust for DST) $NWB#vicidial_campaigns-adaptive_latest_target_gmt$NWE
Latest Server Time: 4 digits only $NWB#vicidial_campaigns-adaptive_latest_server_time$NWE
Adapt Intensity Modifier: $NWB#vicidial_campaigns-adaptive_intensity$NWE
Dial Level Difference Target: $NWB#vicidial_campaigns-adaptive_dl_diff_target$NWE
Next Agent Call: $NWB#vicidial_campaigns-next_agent_call$NWE
Adapt Intensity Modifier: =-40) { - echo "\n"; + $dtl = 'Balanced'; + if ($n<0) {$dtl = 'Less Intense';} + if ($n>0) {$dtl = 'More Intense';} + if ($n == $adaptive_intensity) + {echo "\n";} + else + {echo "\n";} $n--; } -echo " $NWB#vicidial_campaigns-adaptive_intensity$NWE
Script: $script_id