From 152948c424629d9d20d6392b4f4c36d7c61a94e6 Mon Sep 17 00:00:00 2001 From: mattf Date: Sun, 8 Mar 2009 12:42:54 +0000 Subject: [PATCH] Added shift enforcement for agent logins Added vital statistics display(CPU/load/disk) to reports and server modification screens Added configurable max calls per second to servers and system settings git-svn-id: svn://192.168.202.10@1068 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 6 + agc_2-X/trunk/bin/AST_DB_optimize.pl | 183 ++- agc_2-X/trunk/bin/AST_VDauto_dial.pl | 25 +- agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl | 28 +- agc_2-X/trunk/bin/AST_update.pl | 1341 +++++++++-------- .../trunk/extras/MySQL_AST_CREATE_tables.sql | 22 +- agc_2-X/trunk/extras/upgrade_2.0.5.sql | 18 + .../TO_BE_TRANSLATED_2.0.5.txt | 20 + agc_2-X/trunk/www/agc/conf_exten_check.php | 89 +- agc_2-X/trunk/www/agc/vdc_db_query.php | 149 +- agc_2-X/trunk/www/agc/vicidial.php | 253 +++- agc_2-X/trunk/www/vicidial/admin.php | 388 +++-- 12 files changed, 1596 insertions(+), 926 deletions(-) diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index 7110e92d..34145d02 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -262,6 +262,12 @@ NOTE: Upgrading from 1.1.12-3 to 2.0.1 is at the bottom 61. Added options for custom web variables for each agent per in-group and camaign. This is definable in the user modification page +62. Added Agent Shift enforcement options to restrict logins and vicidial + agent activity + +63. Added Server vital statistics(load/CPU/disk) to the reports screen and the + server modification screen + diff --git a/agc_2-X/trunk/bin/AST_DB_optimize.pl b/agc_2-X/trunk/bin/AST_DB_optimize.pl index 28c03572..2c6cd8d1 100644 --- a/agc_2-X/trunk/bin/AST_DB_optimize.pl +++ b/agc_2-X/trunk/bin/AST_DB_optimize.pl @@ -7,7 +7,7 @@ # # It is recommended that you run this program on the local Asterisk machine # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # CHANGES # 60717-1242 - changed to DBI by Marin Blu @@ -16,6 +16,7 @@ # 71109-1725 - fixed vicidial_campaign_stats bug # 71215-0410 - fixed UPDATE/DELETE results # 80909-0555 - added vicidial_campaign_dnc table +# 90307-2025 - Added several new queries and rearranged update/deletes # # default path to astguiclient configuration file: @@ -67,6 +68,102 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA or die "Couldn't connect to database: " . DBI->errstr; + + $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='0', calls_today='0', answers_today='0', drops_today='0', drops_today_pct='0', drops_answers_today_pct='0', calls_hour='0', answers_hour='0', drops_hour='0', drops_hour_pct='0', calls_halfhour='0', answers_halfhour='0', drops_halfhour='0', drops_halfhour_pct='0', calls_fivemin='0', answers_fivemin='0', drops_fivemin='0', drops_fivemin_pct='0', calls_onemin='0', answers_onemin='0', drops_onemin='0', drops_onemin_pct='0', differential_onemin='0', agents_average_onemin='0', balance_trunk_fill='0', status_category_count_1='0', status_category_count_2='0', status_category_count_3='0', status_category_count_4='0';"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_stats records reset|\n";} + } + + $stmtA = "optimize table vicidial_campaign_stats;"; + 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 = "delete from vicidial_campaign_server_stats;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_server_stats records deleted|\n";} + } + + $stmtA = "optimize table vicidial_campaign_server_stats;"; + 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 = "delete from vicidial_live_inbound_agents;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_live_inbound_agents records deleted|\n";} + } + + $stmtA = "optimize table vicidial_live_inbound_agents;"; + 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 = "update vicidial_inbound_group_agents SET calls_today=0;;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_inbound_group_agents call counts reset|\n";} + } + + $stmtA = "optimize table vicidial_inbound_group_agents;"; + 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 = "update vicidial_campaign_agents SET calls_today=0;;"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_agents call counts reset|\n";} + } + + $stmtA = "optimize table vicidial_campaign_agents;"; + 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 call_log;"; if($DB){print STDERR "\n|$stmtA|\n";} if (!$T) { @@ -173,28 +270,6 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA $sthA->finish(); } - $stmtA = "optimize table vicidial_campaign_stats;"; - 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_campaign_server_stats;"; - 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_dnc;"; if($DB){print STDERR "\n|$stmtA|\n";} if (!$T) { @@ -261,46 +336,38 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA $sthA->finish(); } - - $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='0', calls_today='0', answers_today='0', drops_today='0', drops_today_pct='0', drops_answers_today_pct='0', calls_hour='0', answers_hour='0', drops_hour='0', drops_hour_pct='0', calls_halfhour='0', answers_halfhour='0', drops_halfhour='0', drops_halfhour_pct='0', calls_fivemin='0', answers_fivemin='0', drops_fivemin='0', drops_fivemin_pct='0', calls_onemin='0', answers_onemin='0', drops_onemin='0', drops_onemin_pct='0', differential_onemin='0', agents_average_onemin='0', balance_trunk_fill='0', status_category_count_1='0', status_category_count_2='0', status_category_count_3='0', status_category_count_4='0';"; + $stmtA = "optimize table servers;"; if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) - { - $affected_rows = $dbhA->do($stmtA); - if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_stats records reset|\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 = "delete from vicidial_campaign_server_stats;"; + $stmtA = "optimize table vicidial_timeclock_log;"; if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) - { - $affected_rows = $dbhA->do($stmtA); - if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_server_stats records deleted|\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 = "delete from vicidial_live_inbound_agents;"; + $stmtA = "optimize table vicidial_timeclock_status;"; if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) - { - $affected_rows = $dbhA->do($stmtA); - if(!$Q){print STDERR "\n|$affected_rows vicidial_live_inbound_agents records deleted|\n";} - } - - $stmtA = "update vicidial_inbound_group_agents SET calls_today=0;;"; - if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) - { - $affected_rows = $dbhA->do($stmtA); - if(!$Q){print STDERR "\n|$affected_rows vicidial_inbound_group_agents call counts reset|\n";} - } - - $stmtA = "update vicidial_campaign_agents SET calls_today=0;;"; - if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) - { - $affected_rows = $dbhA->do($stmtA); - if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_agents call counts reset|\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(); + } $dbhA->disconnect(); diff --git a/agc_2-X/trunk/bin/AST_VDauto_dial.pl b/agc_2-X/trunk/bin/AST_VDauto_dial.pl index 3a2d728e..2b126d82 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial.pl @@ -74,6 +74,7 @@ # 81020-0125 - Bug fixes from changes to auto_calls deletion changes # 90124-0721 - Added parameter to ensure no auto-dial calls are placed for MANUAL campaigns # 90202-0203 - Added outbound_autodial_active option to halt all dialing +# 90306-1845 - Added configurable calls-per-second option # @@ -313,6 +314,26 @@ while($one_day_interval > 0) $campaigns_update = ''; $CPcount=0; + ##### Get maximum calls per second that this process can send out + $stmtA = "SELECT outbound_calls_per_second 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; + $outbound_calls_per_second = "$aryA[0]"; + } + $sthA->finish(); + + if ( ($outbound_calls_per_second > 0) && ($outbound_calls_per_second < 201) ) + {$per_call_delay = (1000 / $outbound_calls_per_second);} + else + {$per_call_delay = '25';} + + $event_string="SERVER CALLS PER SECOND MAXIMUM SET TO: $outbound_calls_per_second |$per_call_delay|"; + &event_logger; + ############################################# ##### Check if auto-dialing is enabled $stmtA = "SELECT outbound_autodial_active FROM system_settings;"; @@ -921,8 +942,8 @@ while($one_day_interval > 0) $affected_rows = $dbhA->do($stmtA); ### sleep for a five hundredths of a second to not flood the server with new calls - usleep(1*50*1000); - + # usleep(1*50*1000); + usleep(1*$per_call_delay*1000); } } $call_CMPIPct++; 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 d05bcb20..160264b9 100644 --- a/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl +++ b/agc_2-X/trunk/bin/AST_VDauto_dial_FILL.pl @@ -12,7 +12,7 @@ # # Should only be run on one server in a multi-server Asterisk/VICIDIAL cluster # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # CHANGELOG: # 61115-1246 - First build, framework setup, non-functional @@ -24,6 +24,7 @@ # 80713-0624 - Added vicidial_list_last_local_call_time field # 80831-0400 - Added new alt-dial options # 81210-1938 - Fixed callerIDnumber bug +# 90306-1844 - Added configurable calls-per-second option # @@ -265,11 +266,30 @@ while($one_day_interval > 0) } $sthA->finish(); - $event_string="SERVERS WITH TRUNK BALANCE: $balance_servers\n"; + ##### Get maximum calls per second that this process can send out + $stmtA = "SELECT outbound_calls_per_second FROM system_settings;"; + $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; + $outbound_calls_per_second = "$aryA[0]"; + } + $sthA->finish(); + + if ( ($outbound_calls_per_second > 0) && ($outbound_calls_per_second < 201) ) + {$per_call_delay = (1000 / $outbound_calls_per_second);} + else + {$per_call_delay = '25';} + + $event_string ="SERVER CALLS PER SECOND MAXIMUM SET TO: $outbound_calls_per_second |$per_call_delay|\n"; + $event_string.="SERVERS WITH TRUNK BALANCE: $balance_servers\n"; $event_string.="CAMPAIGNS WITH TRUNK SHORTAGE: $camp_counter| TOTAL SHORTAGE: $total_shortage"; &event_logger; + ################################################################################## ##### START LOOP IF THERE ARE BALANCE SERVERS AND THERE ARE SHORTAGES ################################################################################## @@ -744,8 +764,8 @@ while($one_day_interval > 0) $affected_rows = $dbhA->do($stmtA); ### sleep for 2.5 hundredths of a second to not flood the server with new calls - usleep(1*25*1000); - + # usleep(1*25*1000); + usleep(1*$per_call_delay*1000); } } $call_CMPIPct++; diff --git a/agc_2-X/trunk/bin/AST_update.pl b/agc_2-X/trunk/bin/AST_update.pl index 903d96b9..0cc8dc16 100644 --- a/agc_2-X/trunk/bin/AST_update.pl +++ b/agc_2-X/trunk/bin/AST_update.pl @@ -30,7 +30,7 @@ # # It is recommended that you run this program on the local Asterisk machine # -# Copyright (C) 2008 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2009 Matt Florell LICENSE: AGPLv2 # # version changes: # 41228-1659 - modified to compensate for manager output response hiccups @@ -56,9 +56,10 @@ # 61130-1008 - defaults show_channels_format to 1 for non 1.0 version Asterisk # 61227-1659 - added "core show channels concise" for Asterisk 1.4 compatibility # 80111-1850 - fixed server_updater record missing bug +# 90307-1932 - Added servers table stats updating, reformatted code to match standard # -$build = '80111-1850'; +$build = '90307-1932'; # constants $SYSPERF=0; # system performance logging to MySQL server_performance table every 5 seconds @@ -105,6 +106,22 @@ else {$binps = "/usr/bin/ps";} } +### find df binary +$dfbin = ''; +if ( -e ('/bin/df')) {$dfbin = '/bin/df';} +else + { + if ( -e ('/usr/bin/df')) {$dfbin = '/usr/bin/df';} + else + { + if ( -e ('/usr/local/bin/df')) {$dfbin = '/usr/local/bin/df';} + else + { + print "Can't find df binary! Exiting...\n"; + } + } + } + # DB table variables for testing $parked_channels = 'parked_channels'; @@ -118,50 +135,50 @@ else ### begin parsing run-time options ### if (length($ARGV[0])>1) -{ + { $i=0; while ($#ARGV >= $i) - { - $args = "$args $ARGV[$i]"; - $i++; - } + { + $args = "$args $ARGV[$i]"; + $i++; + } if ($args =~ /--help/i) - { - print "allowed run time options:\n [-t] = test\n [-sysperf] = system performance logging\n [-sysperfdebug] = system performance debug output\n [-debug] = verbose debug messages\n [-debugX] = Extra-verbose debug messages\n\n"; - exit; - } + { + print "allowed run time options:\n [-t] = test\n [-sysperf] = system performance logging\n [-sysperfdebug] = system performance debug output\n [-debug] = verbose debug messages\n [-debugX] = Extra-verbose debug messages\n\n"; + exit; + } else - { + { if ($args =~ /-sysperf/i) - { - $SYSPERF=1; # System performance logging flag - } + { + $SYSPERF=1; # System performance logging flag + } if ($args =~ /-sysperfdebug/i) - { - $SYSPERFDB=1; # prints system performance data out to STDOUT - } + { + $SYSPERFDB=1; # prints system performance data out to STDOUT + } if ($args =~ /-debug/i) - { - $DB=1; # Debug flag - } + { + $DB=1; # Debug flag + } if ($args =~ /--debugX/i) - { - $DB=1; - $DBX=1; - print "\n----- SUPER-DUPER DEBUGGING -----\nBUILD: $build\n"; - } + { + $DB=1; + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\nBUILD: $build\n"; + } if ($args =~ /-t/i) - { - $TEST=1; - $T=1; + { + $TEST=1; + $T=1; + } } } -} else -{ -# print "no command line options set\n"; -} + { + # print "no command line options set\n"; + } ### end parsing run-time options ### @@ -233,43 +250,43 @@ $sthArows=$sthA->rows; $rec_count=0; while ($sthArows > $rec_count) { - @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]"; - $DBasterisk_version = "$aryA[11]"; - $DBsys_perf_log = "$aryA[12]"; - $DBvd_server_logs = "$aryA[13]"; - 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 ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;} - 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 ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} - if ($DBsys_perf_log =~ /Y/) {$SYSPERF = '1';} - if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} - $rec_count++; + @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]"; + $DBasterisk_version = "$aryA[11]"; + $DBsys_perf_log = "$aryA[12]"; + $DBvd_server_logs = "$aryA[13]"; + 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 ($DBASTmgrUSERNAMElisten) {$ASTmgrUSERNAMElisten = $DBASTmgrUSERNAMElisten;} + 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 ($DBasterisk_version) {$AST_ver = $DBasterisk_version;} + if ($DBsys_perf_log =~ /Y/) {$SYSPERF = '1';} + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + $rec_count++; } $sthA->finish(); - $show_channels_format = 1; - if ($AST_ver =~ /^1\.0/i) {$show_channels_format = 0;} - if ($AST_ver =~ /^1\.4/i) {$show_channels_format = 2;} - print STDERR "SHOW CHANNELS format: $show_channels_format\n"; +$show_channels_format = 1; +if ($AST_ver =~ /^1\.0/i) {$show_channels_format = 0;} +if ($AST_ver =~ /^1\.4/i) {$show_channels_format = 2;} +print STDERR "SHOW CHANNELS format: $show_channels_format\n"; ##### Check for a server_updater record, and if not present, insert one @@ -293,94 +310,93 @@ if ($SUrec < 1) ##### LOOK FOR ZAP CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS - print STDERR "LOOKING FOR Zap clients assigned to this server:\n"; - $Zap_client_count=0; - $Zap_client_list='|'; - $stmtA = "SELECT extension FROM phones where protocol = 'Zap' and server_ip='$server_ip'"; - if($DB){print STDERR "|$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; - print STDERR $aryA[0],"\n"; - $Zap_client_list .= "$aryA[0]|"; - $Zap_client_count++; - $rec_count++; - } - $sthA->finish(); +print STDERR "LOOKING FOR Zap clients assigned to this server:\n"; +$Zap_client_count=0; +$Zap_client_list='|'; +$stmtA = "SELECT extension FROM phones where protocol = 'Zap' and server_ip='$server_ip'"; +if($DB){print STDERR "|$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; + print STDERR $aryA[0],"\n"; + $Zap_client_list .= "$aryA[0]|"; + $Zap_client_count++; + $rec_count++; + } +$sthA->finish(); ##### LOOK FOR IAX2 CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS - print STDERR "LOOKING FOR IAX2 clients assigned to this server:\n"; - $IAX2_client_count=0; - $IAX2_client_list='|'; - $stmtA = "SELECT extension FROM phones where protocol = 'IAX2' and server_ip='$server_ip'"; - if($DB){print STDERR "|$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; - print STDERR $aryA[0],"\n"; - $IAX2_client_list .= "$aryA[0]|"; - if ($aryA[0] !~ /\@/) - {$IAX2_client_list .= "$aryA[0]$AMP$aryA[0]|";} - else - { - $IAX_user = $aryA[0]; - $IAX_user =~ s/\@.*$//gi; - $IAX2_client_list .= "$IAX_user|"; - } - $IAX2_client_count++; - $rec_count++; - } - $sthA->finish(); +print STDERR "LOOKING FOR IAX2 clients assigned to this server:\n"; +$IAX2_client_count=0; +$IAX2_client_list='|'; +$stmtA = "SELECT extension FROM phones where protocol = 'IAX2' and server_ip='$server_ip'"; +if($DB){print STDERR "|$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; + print STDERR $aryA[0],"\n"; + $IAX2_client_list .= "$aryA[0]|"; + if ($aryA[0] !~ /\@/) + {$IAX2_client_list .= "$aryA[0]$AMP$aryA[0]|";} + else + { + $IAX_user = $aryA[0]; + $IAX_user =~ s/\@.*$//gi; + $IAX2_client_list .= "$IAX_user|"; + } + $IAX2_client_count++; + $rec_count++; + } +$sthA->finish(); ##### LOOK FOR SIP CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS - print STDERR "LOOKING FOR SIP clients assigned to this server:\n"; - $SIP_client_count=0; - $SIP_client_list='|'; - $stmtA = "SELECT extension FROM phones where protocol = 'SIP' and server_ip='$server_ip'"; - if($DB){print STDERR "|$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; - print STDERR $aryA[0],"\n"; - $SIP_client_list .= "$aryA[0]|"; - if ($aryA[0] !~ /\@/) - {$SIP_client_list .= "$aryA[0]$AMP$aryA[0]|";} - else - { - $SIP_user = $aryA[0]; - $SIP_user =~ s/\@.*$//gi; - $SIP_client_list .= "$SIP_user|"; - } - $SIP_client_count++; - $rec_count++; - } - $sthA->finish(); +print STDERR "LOOKING FOR SIP clients assigned to this server:\n"; +$SIP_client_count=0; +$SIP_client_list='|'; +$stmtA = "SELECT extension FROM phones where protocol = 'SIP' and server_ip='$server_ip'"; +if($DB){print STDERR "|$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; + print STDERR $aryA[0],"\n"; + $SIP_client_list .= "$aryA[0]|"; + if ($aryA[0] !~ /\@/) + {$SIP_client_list .= "$aryA[0]$AMP$aryA[0]|";} + else + { + $SIP_user = $aryA[0]; + $SIP_user =~ s/\@.*$//gi; + $SIP_client_list .= "$SIP_user|"; + } + $SIP_client_count++; + $rec_count++; + } +$sthA->finish(); - print STDERR "Zap Clients: $Zap_client_list\n"; - print STDERR "IAX2 Clients: $IAX2_client_list\n"; - print STDERR "SIP Clients: $SIP_client_list\n"; +print STDERR "Zap Clients: $Zap_client_list\n"; +print STDERR "IAX2 Clients: $IAX2_client_list\n"; +print STDERR "SIP Clients: $SIP_client_list\n"; $one_day_interval = 12; # 2 hour loops for one day while($one_day_interval > 0) -{ - + { $event_string="STARTING NEW MANAGER TELNET CONNECTION||ATTEMPT|ONE DAY INTERVAL:$one_day_interval|"; &event_logger; -if (!$telnet_port) {$telnet_port = '5038';} + if (!$telnet_port) {$telnet_port = '5038';} ### connect to asterisk manager through telnet $t = new Net::Telnet (Port => $telnet_port, @@ -397,102 +413,100 @@ if (!$telnet_port) {$telnet_port = '5038';} $event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|ONE DAY INTERVAL:$one_day_interval|"; &event_logger; + $gather_stats_first=1; $endless_loop=5769999; # 30 days minutes at .45 seconds per loop while($endless_loop > 0) - { - - + { @DBchannels=@MT; @DBsips=@MT; @list_channels=@MT; @test_channels=@MT; - &get_current_channels; - - &validate_parked_channels; + &get_current_channels; + &validate_parked_channels; - $t->buffer_empty; - if ($show_channels_format < 1) - { - @list_channels = $t->cmd(String => "Action: Command\nCommand: show channels\n\n", Prompt => '/--END COMMAND-.*/'); - } - if ($show_channels_format == 1) - { - @list_channels = $t->cmd(String => "Action: Command\nCommand: show channels concise\n\n", Prompt => '/--END COMMAND-.*/'); - } - if ($show_channels_format > 1) - { - @list_channels = $t->cmd(String => "Action: Command\nCommand: core show channels concise\n\n", Prompt => '/--END COMMAND-.*/'); - } - - ##### TEST CHANNELS ZAP/IAX2/Local TO SEE IF THERE WAS A LARGE HICCUP IN OUTPUT FROM PREVIOUS OUTPUT - @test_channels=@list_channels; - $test_zap_count=0; - $test_iax_count=0; - $test_local_count=0; - $test_sip_count=0; - $s=0; - foreach(@test_channels) - { - chomp($test_channels[$s]); - if($DBX){print "$s|$test_channels[$s]\n";} - $test_channels[$s] =~ s/Congestion\s+\(Empty\)/ SIP\/CONGEST/gi; - $test_channels[$s] =~ s/\(Outgoing Line\)|\(None\)/SIP\/ring/gi; - $test_channels[$s] =~ s/\(Empty\)/SIP\/internal/gi; - if (!$show_channels_format) + $t->buffer_empty; + if ($show_channels_format < 1) { - $test_channels[$s] =~ s/^\s*|\s*$//gi; - $test_channels[$s] =~ s/\(.*\)//gi; + @list_channels = $t->cmd(String => "Action: Command\nCommand: show channels\n\n", Prompt => '/--END COMMAND-.*/'); } - else + if ($show_channels_format == 1) { - $EXcount = 0; - $EXcount = @{[$test_channels[$s] =~ /\!/g]}; - if ($EXcount > 10) + @list_channels = $t->cmd(String => "Action: Command\nCommand: show channels concise\n\n", Prompt => '/--END COMMAND-.*/'); + } + if ($show_channels_format > 1) + { + @list_channels = $t->cmd(String => "Action: Command\nCommand: core show channels concise\n\n", Prompt => '/--END COMMAND-.*/'); + } + + ##### TEST CHANNELS ZAP/IAX2/Local TO SEE IF THERE WAS A LARGE HICCUP IN OUTPUT FROM PREVIOUS OUTPUT + @test_channels=@list_channels; + $test_zap_count=0; + $test_iax_count=0; + $test_local_count=0; + $test_sip_count=0; + $s=0; + foreach(@test_channels) + { + chomp($test_channels[$s]); + if($DBX){print "$s|$test_channels[$s]\n";} + $test_channels[$s] =~ s/Congestion\s+\(Empty\)/ SIP\/CONGEST/gi; + $test_channels[$s] =~ s/\(Outgoing Line\)|\(None\)/SIP\/ring/gi; + $test_channels[$s] =~ s/\(Empty\)/SIP\/internal/gi; + if (!$show_channels_format) { - @test_chan_12 = split(/\!/, $test_channels[$s]); + $test_channels[$s] =~ s/^\s*|\s*$//gi; + $test_channels[$s] =~ s/\(.*\)//gi; } else { - @test_chan_12 = split(/:/, $test_channels[$s]); + $EXcount = 0; + $EXcount = @{[$test_channels[$s] =~ /\!/g]}; + if ($EXcount > 10) + { + @test_chan_12 = split(/\!/, $test_channels[$s]); + } + else + { + @test_chan_12 = split(/:/, $test_channels[$s]); + } + # @test_chan_12 = split(/:/, $test_channels[$s]); + if (length($test_chan_12[6])<2) {$test_chan_12[6] = 'SIP/ring';} + $test_channels[$s] = "$test_chan_12[0] $test_chan_12[6]"; } - # @test_chan_12 = split(/:/, $test_channels[$s]); - if (length($test_chan_12[6])<2) {$test_chan_12[6] = 'SIP/ring';} - $test_channels[$s] = "$test_chan_12[0] $test_chan_12[6]"; - } - if ($test_channels[$s] =~ /^Zap|^IAX2|^SIP|^Local/) - { - if ($test_channels[$s] =~ /^(\S+)\s+.+\s+(\S+)$/) + if ($test_channels[$s] =~ /^Zap|^IAX2|^SIP|^Local/) { - $channel = $1; - $extension = $2; - if ($show_channels_format) - {$extension =~ s/^.*\(|\).*$//gi;} - $extension =~ s/^SIP\/|-\S+$//gi; - $extension =~ s/\|.*//gi; - if ($channel =~ /^SIP/) {$test_sip_count++;} - if ($channel =~ /^Local/) {$test_local_count++;} - if ($IAX2_client_count) + if ($test_channels[$s] =~ /^(\S+)\s+.+\s+(\S+)$/) { - $channel_match=$channel; - $channel_match =~ s/\/\d+$|-\d+$//gi; - $channel_match =~ s/^IAX2\///gi; - $channel_match =~ s/\*/\\\*/gi; - if ($IAX2_client_list =~ /\|$channel_match\|/i) {$test_iax_count++;} - } - if ($Zap_client_count) - { - $channel_match=$channel; - $channel_match =~ s/^Zap\///gi; - $channel_match =~ s/\*/\\\*/gi; - if ($Zap_client_list =~ /\|$channel_match\|/i) {$test_zap_count++;} + $channel = $1; + $extension = $2; + if ($show_channels_format) + {$extension =~ s/^.*\(|\).*$//gi;} + $extension =~ s/^SIP\/|-\S+$//gi; + $extension =~ s/\|.*//gi; + if ($channel =~ /^SIP/) {$test_sip_count++;} + if ($channel =~ /^Local/) {$test_local_count++;} + if ($IAX2_client_count) + { + $channel_match=$channel; + $channel_match =~ s/\/\d+$|-\d+$//gi; + $channel_match =~ s/^IAX2\///gi; + $channel_match =~ s/\*/\\\*/gi; + if ($IAX2_client_list =~ /\|$channel_match\|/i) {$test_iax_count++;} + } + if ($Zap_client_count) + { + $channel_match=$channel; + $channel_match =~ s/^Zap\///gi; + $channel_match =~ s/\*/\\\*/gi; + if ($Zap_client_list =~ /\|$channel_match\|/i) {$test_zap_count++;} + } } } + $s++; } - $s++; - } @@ -562,13 +576,13 @@ if (!$telnet_port) {$telnet_port = '5038';} else { $UD_bad_grab=0; - if ( ($endless_loop =~ /0$/) && ($SYSPERF) ) + if ( ( ($endless_loop =~ /0$/) && ($SYSPERF) ) || ($endless_loop =~ /00$/) || ($gather_stats_first >= 1) ) { $cpuUSERcent=0; $cpuSYSTcent=0; $cpuIDLEcent=0; ### get processor usage seconds ### # cpu 924841 211725 270473 6961811 @cpuUSE = `$bincat /proc/stat`; - if ($cpuUSE[0] =~ /cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) + if ($cpuUSE[0] =~ /cpu\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) { $cpuUSER = ($1 + $2); $cpuSYST = $3; @@ -607,140 +621,173 @@ if (!$telnet_port) {$telnet_port = '5038';} if ($SYSPERF_rec) {$recording_count = ($test_local_count / 2)} else {$recording_count=0;} - if ($SYSPERFDB) - {print "$serverLOAD $MEMfree $MEMused $serverPROCESSES $#list_channels $cpuUSERcent $cpuSYSTcent $cpuIDLEcent\n";} + if ($SYSPERF) + { + if ($SYSPERFDB) + {print "$serverLOAD $MEMfree $MEMused $serverPROCESSES $#list_channels $cpuUSERcent $cpuSYSTcent $cpuIDLEcent\n";} - $stmtA = "INSERT INTO server_performance (start_time,server_ip,sysload,freeram,usedram,processes,channels_total,trunks_total,clients_total,clients_zap,clients_iax,clients_local,clients_sip,live_recordings,cpu_user_percent,cpu_system_percent,cpu_idle_percent) values('$now_date','$server_ip','$serverLOAD','$MEMfree','$MEMused','$serverPROCESSES','$#list_channels','$channel_counter','$sip_counter','$test_zap_count','$test_iax_count','$test_local_count','$test_sip_count','$recording_count','$cpuUSERcent','$cpuSYSTcent','$cpuIDLEcent')"; - if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} - $affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + $stmtA = "INSERT INTO server_performance (start_time,server_ip,sysload,freeram,usedram,processes,channels_total,trunks_total,clients_total,clients_zap,clients_iax,clients_local,clients_sip,live_recordings,cpu_user_percent,cpu_system_percent,cpu_idle_percent) values('$now_date','$server_ip','$serverLOAD','$MEMfree','$MEMused','$serverPROCESSES','$#list_channels','$channel_counter','$sip_counter','$test_zap_count','$test_iax_count','$test_local_count','$test_sip_count','$recording_count','$cpuUSERcent','$cpuSYSTcent','$cpuIDLEcent')"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + } + if ( ($endless_loop =~ /00$/) || ($gather_stats_first >= 1) ) + { + ### get disk space usage ### + $disk_usage=''; + @serverDISK = `$dfbin -B 1048576`; + #Filesystem 1M-blocks Used Available Use% Mounted on + #/dev/sda1 30030 6867 21613 0% / + + $gather_stats_first=0; + $channels_total=0; + if ($#list_channels > 0) + {$channels_total = ($#list_channels - 1);} + $ct=0; $ct_PCT=0; + foreach(@serverDISK) + { + if ($serverDISK[$ct] =~ /(\d+\%)/) + { + $ct_PCT++; + $usage = $1; + $usage =~ s/\%//gi; + $disk_usage .= "$ct_PCT $usage|"; + } + $ct++; + } + + $stmtA = "UPDATE servers SET sysload='$serverLOAD',channels_total='$channels_total',cpu_idle_percent='$cpuIDLEcent',disk_usage='$disk_usage' where server_ip='$server_ip';"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + } } } if ($endless_loop =~ /00$/) { ##### LOOK FOR ZAP CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS - print STDERR "LOOKING FOR Zap clients assigned to this server:\n"; - $Zap_client_count=0; - $Zap_client_list='|'; - $stmtA = "SELECT extension FROM phones where protocol = 'Zap' and server_ip='$server_ip'"; - if($DB){print STDERR "|$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; - print STDERR $aryA[0],"\n"; - $Zap_client_list .= "$aryA[0]|"; - $Zap_client_count++; - $rec_count++; - } - $sthA->finish(); + print STDERR "LOOKING FOR Zap clients assigned to this server:\n"; + $Zap_client_count=0; + $Zap_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'Zap' and server_ip='$server_ip'"; + if($DB){print STDERR "|$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; + print STDERR $aryA[0],"\n"; + $Zap_client_list .= "$aryA[0]|"; + $Zap_client_count++; + $rec_count++; + } + $sthA->finish(); ##### LOOK FOR IAX2 CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS - print STDERR "LOOKING FOR IAX2 clients assigned to this server:\n"; - $IAX2_client_count=0; - $IAX2_client_list='|'; - $stmtA = "SELECT extension FROM phones where protocol = 'IAX2' and server_ip='$server_ip'"; - if($DB){print STDERR "|$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) + print STDERR "LOOKING FOR IAX2 clients assigned to this server:\n"; + $IAX2_client_count=0; + $IAX2_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'IAX2' and server_ip='$server_ip'"; + if($DB){print STDERR "|$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; + print STDERR $aryA[0],"\n"; + $IAX2_client_list .= "$aryA[0]|"; + if ($aryA[0] !~ /\@/) + {$IAX2_client_list .= "$aryA[0]$AMP$aryA[0]|";} + else { - @aryA = $sthA->fetchrow_array; - print STDERR $aryA[0],"\n"; - $IAX2_client_list .= "$aryA[0]|"; - if ($aryA[0] !~ /\@/) - {$IAX2_client_list .= "$aryA[0]$AMP$aryA[0]|";} - else - { - $IAX_user = $aryA[0]; - $IAX_user =~ s/\@.*$//gi; - $IAX2_client_list .= "$IAX_user|"; - } - $IAX2_client_count++; - $rec_count++; + $IAX_user = $aryA[0]; + $IAX_user =~ s/\@.*$//gi; + $IAX2_client_list .= "$IAX_user|"; } - $sthA->finish(); + $IAX2_client_count++; + $rec_count++; + } + $sthA->finish(); ##### LOOK FOR SIP CLIENTS AS DEFINED IN THE phones TABLE SO THEY ARE NOT MISLABELED AS TRUNKS - print STDERR "LOOKING FOR SIP clients assigned to this server:\n"; - $SIP_client_count=0; - $SIP_client_list='|'; - $stmtA = "SELECT extension FROM phones where protocol = 'SIP' and server_ip='$server_ip'"; - if($DB){print STDERR "|$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) + print STDERR "LOOKING FOR SIP clients assigned to this server:\n"; + $SIP_client_count=0; + $SIP_client_list='|'; + $stmtA = "SELECT extension FROM phones where protocol = 'SIP' and server_ip='$server_ip'"; + if($DB){print STDERR "|$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; + print STDERR $aryA[0],"\n"; + $SIP_client_list .= "$aryA[0]|"; + if ($aryA[0] !~ /\@/) + {$SIP_client_list .= "$aryA[0]$AMP$aryA[0]|";} + else { - @aryA = $sthA->fetchrow_array; - print STDERR $aryA[0],"\n"; - $SIP_client_list .= "$aryA[0]|"; - if ($aryA[0] !~ /\@/) - {$SIP_client_list .= "$aryA[0]$AMP$aryA[0]|";} - else - { - $SIP_user = $aryA[0]; - $SIP_user =~ s/\@.*$//gi; - $SIP_client_list .= "$SIP_user|"; - } - $SIP_client_count++; - $rec_count++; + $SIP_user = $aryA[0]; + $SIP_user =~ s/\@.*$//gi; + $SIP_client_list .= "$SIP_user|"; } - $sthA->finish(); + $SIP_client_count++; + $rec_count++; + } + $sthA->finish(); - print STDERR "Zap Clients: $Zap_client_list\n"; - print STDERR "IAX2 Clients: $IAX2_client_list\n"; - print STDERR "SIP Clients: $SIP_client_list\n"; + print STDERR "Zap Clients: $Zap_client_list\n"; + print STDERR "IAX2 Clients: $IAX2_client_list\n"; + print STDERR "SIP Clients: $SIP_client_list\n"; ### Grab Server values from the database - $stmtA = "SELECT sys_perf_log,vd_server_logs 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; - $rec_count=0; - while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - $DBsys_perf_log = "$aryA[0]"; - $DBvd_server_logs = "$aryA[1]"; - if ($DBsys_perf_log =~ /Y/) {$SYSPERF = '1';} - else {$SYSPERF = '0';} - if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} - else {$SYSLOG = '0';} - $rec_count++; - } - $sthA->finish(); + $stmtA = "SELECT sys_perf_log,vd_server_logs 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; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + $DBsys_perf_log = "$aryA[0]"; + $DBvd_server_logs = "$aryA[1]"; + if ($DBsys_perf_log =~ /Y/) {$SYSPERF = '1';} + else {$SYSPERF = '0';} + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + $rec_count++; + } + $sthA->finish(); if ($SYSPERFDB) {print "SYSPERF RELOAD: $DBsys_perf_log:$SYSPERF|$DBvd_server_logs:$SYSLOG\n";} } - @list_chan_12=@MT; - $EXcount = 0; - $EXcount = @{[$list_channels[2] =~ /\!/g]}; - if ($EXcount > 10) - { - @list_chan_12 = split(/\!/, $list_channels[2]); - } - else - { - @list_chan_12 = split(/:/, $list_channels[2]); - } - if( ($DB) && ($show_channels_format) ) {print "concise: $#list_chan_12\n";} - if ( ( ( ($list_channels[1] =~ /State Appl\./) or ($list_channels[2] =~ /State Appl\.|Application\(Data\)/) or ($list_channels[3] =~ /State Appl\.|Application\(Data\)/) ) || ($#list_chan_12 > 8) ) && (!$UD_bad_grab) ) - { + @list_chan_12=@MT; + $EXcount = 0; + $EXcount = @{[$list_channels[2] =~ /\!/g]}; + if ($EXcount > 10) + { + @list_chan_12 = split(/\!/, $list_channels[2]); + } + else + { + @list_chan_12 = split(/:/, $list_channels[2]); + } + if( ($DB) && ($show_channels_format) ) + {print "concise: $#list_chan_12 loop: $endless_loop\n";} + if ( ( ( ($list_channels[1] =~ /State Appl\./) or ($list_channels[2] =~ /State Appl\.|Application\(Data\)/) or ($list_channels[3] =~ /State Appl\.|Application\(Data\)/) ) || ($#list_chan_12 > 8) ) && (!$UD_bad_grab) ) + { - $c=0; + $c=0; if($DB){print "lines: $#list_channels\n";} if($DB){print "DBchn: $#DBchannels\n";} if($DB){print "DBsip: $#DBsips\n";} - foreach(@list_channels) - { - # $DBchannels =~ s/^\|//g; + foreach(@list_channels) + { + # $DBchannels =~ s/^\|//g; chomp($list_channels[$c]); if( ($DB) or ($UD_bad_grab) ){print "-|$c|$list_channels[$c]|\n";} @@ -768,140 +815,139 @@ if (!$telnet_port) {$telnet_port = '5038';} $list_channels[$c] = "$list_chan_12[0] $list_chan_12[6]"; } $list_SIP[$c] = $list_channels[$c]; - if( ($DB) or ($UD_bad_grab) ){print "+|$c|$list_channels[$c]|\n\n";} + if( ($DB) or ($UD_bad_grab) ){print "+|$c|$list_channels[$c]|\n\n";} - ########## PARSE EACH LINE TO DETERMINE WHETHER IT IS TRUNK OR CLIENT AND PUT IN APPROPRIATE TABLE - if ($list_channels[$c] =~ /^Zap|^IAX2|^SIP|^Local/) - { - if ($list_channels[$c] =~ /^(\S+)\s+.+\s+(\S+)$/) + ########## PARSE EACH LINE TO DETERMINE WHETHER IT IS TRUNK OR CLIENT AND PUT IN APPROPRIATE TABLE + if ($list_channels[$c] =~ /^Zap|^IAX2|^SIP|^Local/) { - $line_type = ''; - $channel = $1; - $extension = $2; - $channel_data = $extension; - if ($show_channels_format) + if ($list_channels[$c] =~ /^(\S+)\s+.+\s+(\S+)$/) { - $extension =~ s/^.*\(|\).*$//gi; - #### new data in 1.2 for future use - # SIP/cc160-7b91:default:917274514920:3:Up:Dial:Zap/g2/17274514920|30|o:cc160::3:9:Zap/25-1 + $line_type = ''; + $channel = $1; + $extension = $2; + $channel_data = $extension; + if ($show_channels_format) + { + $extension =~ s/^.*\(|\).*$//gi; + #### new data in 1.2 for future use + # SIP/cc160-7b91:default:917274514920:3:Up:Dial:Zap/g2/17274514920|30|o:cc160::3:9:Zap/25-1 # Zap/30-1:demo:010*010*010*012*8600091:1:Up:Dial:IAX2/TESTast2:test@10.10.10.12:4569/8600051|25|o:::3:123:IAX2/TESTast2-29 # Zap/9-1:demo:990009*CL_UMGCOF_L**6317906**9545541833*13678*:2:Up:Dial:Zap/r3/90009*CL_UMGCOF_L**6317906**9545541833*13678*|120|o:::3:334:Zap/82-1 - # $channel = $list_chan_12[0]; - # $channel_data = $list_chan_12[0]; - # $context = $list_chan_12[1]; - # $dialed = $list_chan_12[2]; - # $priority = $list_chan_12[3]; - # $state = $list_chan_12[4]; - # $extension = $list_chan_12[6]; - # $callerid = $list_chan_12[7]; - # $duration = $list_chan_12[10]; - # $bridged = $list_chan_12[11]; - } - $extension =~ s/^SIP\/|-\S+$//gi; - $extension =~ s/\|.*//gi; - $QRYchannel = "$channel$US$extension"; + # $channel = $list_chan_12[0]; + # $channel_data = $list_chan_12[0]; + # $context = $list_chan_12[1]; + # $dialed = $list_chan_12[2]; + # $priority = $list_chan_12[3]; + # $state = $list_chan_12[4]; + # $extension = $list_chan_12[6]; + # $callerid = $list_chan_12[7]; + # $duration = $list_chan_12[10]; + # $bridged = $list_chan_12[11]; + } + $extension =~ s/^SIP\/|-\S+$//gi; + $extension =~ s/\|.*//gi; + $QRYchannel = "$channel$US$extension"; - if( ($DB) or ($UD_bad_grab) ){print "channel: |$channel|\n";} - if( ($DB) or ($UD_bad_grab) ){print "extension: |$extension|\n";} - if( ($DB) or ($UD_bad_grab) ){print "QRYchannel:|$QRYchannel|\n";} + if( ($DB) or ($UD_bad_grab) ){print "channel: |$channel|\n";} + if( ($DB) or ($UD_bad_grab) ){print "extension: |$extension|\n";} + if( ($DB) or ($UD_bad_grab) ){print "QRYchannel:|$QRYchannel|\n";} - if ($channel =~ /^SIP|^Zap|^IAX2/) {$line_type = 'TRUNK';} - if ($channel =~ /^Local/) {$line_type = 'CLIENT';} - if ($IAX2_client_count) - { - $channel_match=$channel; - $channel_match =~ s/\/\d+$|-\d+$//gi; - $channel_match =~ s/^IAX2\///gi; - $channel_match =~ s/\*/\\\*/gi; - # print "checking for IAX2 client: |$channel_match|\n"; - if ($IAX2_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} - } - if ($Zap_client_count) - { - $channel_match=$channel; - $channel_match =~ s/^Zap\///gi; - $channel_match =~ s/\*/\\\*/gi; - # print "checking for Zap client: |$channel_match|\n"; - if ($Zap_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} - } - if ($SIP_client_count) - { - $channel_match=$channel; - $channel_match =~ s/-\S+$//gi; - $channel_match =~ s/^SIP\///gi; - $channel_match =~ s/\*/\\\*/gi; - # print "checking for SIP client: |$channel_match|\n"; - if ($SIP_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} - } + if ($channel =~ /^SIP|^Zap|^IAX2/) {$line_type = 'TRUNK';} + if ($channel =~ /^Local/) {$line_type = 'CLIENT';} + if ($IAX2_client_count) + { + $channel_match=$channel; + $channel_match =~ s/\/\d+$|-\d+$//gi; + $channel_match =~ s/^IAX2\///gi; + $channel_match =~ s/\*/\\\*/gi; + # print "checking for IAX2 client: |$channel_match|\n"; + if ($IAX2_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} + } + if ($Zap_client_count) + { + $channel_match=$channel; + $channel_match =~ s/^Zap\///gi; + $channel_match =~ s/\*/\\\*/gi; + # print "checking for Zap client: |$channel_match|\n"; + if ($Zap_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} + } + if ($SIP_client_count) + { + $channel_match=$channel; + $channel_match =~ s/-\S+$//gi; + $channel_match =~ s/^SIP\///gi; + $channel_match =~ s/\*/\\\*/gi; + # print "checking for SIP client: |$channel_match|\n"; + if ($SIP_client_list =~ /\|$channel_match\|/i) {$line_type = 'CLIENT';} + } - if ($line_type eq 'TRUNK') - { - if( ($DB) or ($UD_bad_grab) ){print "current channels: $#DBchannels\n";} + if ($line_type eq 'TRUNK') + { + if( ($DB) or ($UD_bad_grab) ){print "current channels: $#DBchannels\n";} $k=0; $channel_in_DB=0; - foreach(@DBchannels) - { - if ( ($DBchannels[$k] eq "$QRYchannel") && (!$channel_in_DB) ) + foreach(@DBchannels) { - $DBchannels[$k] = ''; - $channel_in_DB++; + if ( ($DBchannels[$k] eq "$QRYchannel") && (!$channel_in_DB) ) + { + $DBchannels[$k] = ''; + $channel_in_DB++; + } + if( ($DB) or ($UD_bad_grab) ){print "DB $k|$DBchannels[$k]| |";} + $k++; + } + + if ( (!$channel_in_DB) && (length($QRYchannel)>3) ) + { + $stmtA = "INSERT INTO $live_channels (channel,server_ip,extension,channel_data) values('$channel','$server_ip','$extension','$channel_data')"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n"; } - if( ($DB) or ($UD_bad_grab) ){print "DB $k|$DBchannels[$k]| |";} - $k++; } - if ( (!$channel_in_DB) && (length($QRYchannel)>3) ) + if ($line_type eq 'CLIENT') { - $stmtA = "INSERT INTO $live_channels (channel,server_ip,extension,channel_data) values('$channel','$server_ip','$extension','$channel_data')"; - if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} - $affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n"; - } - } - - if ($line_type eq 'CLIENT') - { - if( ($DB) or ($UD_bad_grab) ){print "current sips: $#DBsips\n";} + if( ($DB) or ($UD_bad_grab) ){print "current sips: $#DBsips\n";} $k=0; $sipchan_in_DB=0; - foreach(@DBsips) - { - if ( ($DBsips[$k] eq "$QRYchannel") && (!$sipchan_in_DB) ) + foreach(@DBsips) { - $DBsips[$k] = ''; - $sipchan_in_DB++; + if ( ($DBsips[$k] eq "$QRYchannel") && (!$sipchan_in_DB) ) + { + $DBsips[$k] = ''; + $sipchan_in_DB++; + } + if( ($DB) or ($UD_bad_grab) ){print "DB $k|$DBsips[$k]| |";} + $k++; } - if( ($DB) or ($UD_bad_grab) ){print "DB $k|$DBsips[$k]| |";} - $k++; - } - if ( (!$sipchan_in_DB) && (length($QRYchannel)>3) ) - { - $stmtA = "INSERT INTO $live_sip_channels (channel,server_ip,extension,channel_data) values('$channel','$server_ip','$extension','$channel_data')"; - if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} - $affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + if ( (!$sipchan_in_DB) && (length($QRYchannel)>3) ) + { + $stmtA = "INSERT INTO $live_sip_channels (channel,server_ip,extension,channel_data) values('$channel','$server_ip','$extension','$channel_data')"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtA|\n";} + $affected_rows = $dbhA->do($stmtA) or die "Couldn't execute query: |$stmtA|\n"; + } } } } + + $c++; } - - $c++; - } - if($DB){print "COUNT: $c|$#list_channels|$endless_loop\n";} - + if($DB){print "COUNT: $c|$#list_channels|$endless_loop\n";} if ($#DBchannels >= 0) { - $d=0; + $d=0; foreach(@DBchannels) { if (length($DBchannels[$d])>4) { - ($DELchannel, $DELextension) = split(/\_\_/, $DBchannels[$d]); - $stmtB = "DELETE FROM $live_channels where server_ip='$server_ip' and channel='$DELchannel' and extension='$DELextension' limit 1"; - if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} - $affected_rows = $dbhA->do($stmtB); + ($DELchannel, $DELextension) = split(/\_\_/, $DBchannels[$d]); + $stmtB = "DELETE FROM $live_channels where server_ip='$server_ip' and channel='$DELchannel' and extension='$DELextension' limit 1"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} + $affected_rows = $dbhA->do($stmtB); } $d++; } @@ -909,104 +955,101 @@ if (!$telnet_port) {$telnet_port = '5038';} if ($#DBsips >= 0) { - $d=0; + $d=0; foreach(@DBsips) { if (length($DBsips[$d])>4) { - ($DELchannel, $DELextension) = split(/\_\_/, $DBsips[$d]); - $stmtB = "DELETE FROM $live_sip_channels where server_ip='$server_ip' and channel='$DELchannel' and extension='$DELextension' limit 1"; - if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} - $affected_rows = $dbhA->do($stmtB); + ($DELchannel, $DELextension) = split(/\_\_/, $DBsips[$d]); + $stmtB = "DELETE FROM $live_sip_channels where server_ip='$server_ip' and channel='$DELchannel' and extension='$DELextension' limit 1"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} + $affected_rows = $dbhA->do($stmtB); } $d++; } } - ### sleep for 45 hundredths of a second - usleep(1*450*1000); + ### sleep for 45 hundredths of a second + usleep(1*450*1000); - $endless_loop--; - if($DB){print STDERR "\nloop counter: |$endless_loop|\n";} + $endless_loop--; + if($DB){print STDERR "\nloop counter: |$endless_loop|\n";} - ### putting a blank file called "update.kill" in a directory will automatically safely kill this program - if (-e "$PATHhome/update.kill") - { - unlink("$PATHhome/update.kill"); - $endless_loop=0; - $one_day_interval=0; - print "\nPROCESS KILLED MANUALLY... EXITING\n\n" - } - - $bad_grabber_counter=0; - $no_channels_12_counter=0; - } - - else - { - if ( ($list_channels[1] !~ /Privilege: Command/) && ($show_channels_format) ) - { - $bad_grabber_counter++; - if($DB){print STDERR "\nbad grab, trying again\n";} - ### sleep for 20 hundredths of a second - usleep(1*200*1000); - - $event_string="BAD GRAB TRYING AGAIN|BAD_GRABS: $bad_grabber_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|"; - &event_logger; - - if ($bad_grabber_counter > 100) + ### putting a blank file called "update.kill" in a directory will automatically safely kill this program + if (-e "$PATHhome/update.kill") { + unlink("$PATHhome/update.kill"); $endless_loop=0; - $event_string="TOO MANY BAD GRABS, STARTING NEW CONNECTION|BAD_GRABS: $bad_grabber_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|"; - &event_logger; - $bad_grabber_counter=0; + $one_day_interval=0; + print "\nPROCESS KILLED MANUALLY... EXITING\n\n" } + + $bad_grabber_counter=0; + $no_channels_12_counter=0; } + else { - $no_channels_12_counter++; - $event_string="NO CHANNELS HERE|COUNTER: $no_channels_12_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|$list_channels[1]"; - &event_logger; - - if($DBX) {print "*|EMPTY CHANNELS: $no_channels_12_counter|$#list_channels|$list_channels[1]";} - - ### sleep for 40 hundredths of a second - usleep(1*400*1000); - if ($no_channels_12_counter == 3) + if ( ($list_channels[1] !~ /Privilege: Command/) && ($show_channels_format) ) { - ### there are no channels, delete all from live_channels, live_sip_channels - $event_string="NO CHANNELS HERE|COUNTER: $no_channels_12_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|$list_channels[1]"; - &event_logger; - $stmtB = "DELETE FROM $live_sip_channels where server_ip='$server_ip'"; - if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} - $affected_rows = $dbhA->do($stmtB); - $stmtB = "DELETE FROM $live_channels where server_ip='$server_ip'"; - if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} - $affected_rows = $dbhA->do($stmtB); - } + $bad_grabber_counter++; + if($DB){print STDERR "\nbad grab, trying again\n";} + ### sleep for 20 hundredths of a second + usleep(1*200*1000); + $event_string="BAD GRAB TRYING AGAIN|BAD_GRABS: $bad_grabber_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + + if ($bad_grabber_counter > 100) + { + $endless_loop=0; + $event_string="TOO MANY BAD GRABS, STARTING NEW CONNECTION|BAD_GRABS: $bad_grabber_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + $bad_grabber_counter=0; + } + } + else + { + $no_channels_12_counter++; + $event_string="NO CHANNELS HERE|COUNTER: $no_channels_12_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|$list_channels[1]"; + &event_logger; + + if($DBX) {print "*|EMPTY CHANNELS: $no_channels_12_counter|$#list_channels|$list_channels[1]";} + + $endless_loop--; + ### sleep for 40 hundredths of a second + usleep(1*400*1000); + if ($no_channels_12_counter == 3) + { + ### there are no channels, delete all from live_channels, live_sip_channels + $event_string="NO CHANNELS HERE|COUNTER: $no_channels_12_counter|$endless_loop|ONE DAY INTERVAL:$one_day_interval|$list_channels[1]"; + &event_logger; + $stmtB = "DELETE FROM $live_sip_channels where server_ip='$server_ip'"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} + $affected_rows = $dbhA->do($stmtB); + $stmtB = "DELETE FROM $live_channels where server_ip='$server_ip'"; + if( ($DB) or ($UD_bad_grab) ){print STDERR "\n|$stmtB|\n";} + $affected_rows = $dbhA->do($stmtB); + } + } } } - } + if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";} + $event_string='HANGING UP|'; + &event_logger; - if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...\n";} + @hangup = $t->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/"); - $event_string='HANGING UP|'; - &event_logger; - - @hangup = $t->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/"); - - $ok = $t->close; + $ok = $t->close; $one_day_interval--; + } -} - - $event_string='CLOSING DB CONNECTION|'; - &event_logger; +$event_string='CLOSING DB CONNECTION|'; +&event_logger; $dbhA->disconnect(); @@ -1028,58 +1071,57 @@ exit; # the asterisk MySQL database to be compared to the Asterisk Manager results ####################################################################### sub get_current_channels -{ -$channel_counter=0; -$sip_counter=0; -$zap_client_counter=0; -$iax_client_counter=0; -$local_client_counter=0; -$sip_client_counter=0; + { + $channel_counter=0; + $sip_counter=0; + $zap_client_counter=0; + $iax_client_counter=0; + $local_client_counter=0; + $sip_client_counter=0; if($DB){print STDERR "\n|SELECT channel,extension FROM $live_channels where server_ip = '$server_ip'|\n";} -$stmtA = "SELECT channel,extension FROM $live_channels 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; -$rec_count=0; -while ($sthArows > $rec_count) - { - @aryA = $sthA->fetchrow_array; - if($DB){print STDERR $aryA[0],"|", $aryA[1],"\n";} - $DBchannels[$channel_counter] = "$aryA[0]$US$aryA[1]"; - $channel_counter++; - $rec_count++; - } -$sthA->finish(); + $stmtA = "SELECT channel,extension FROM $live_channels 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; + $rec_count=0; + while ($sthArows > $rec_count) + { + @aryA = $sthA->fetchrow_array; + if($DB){print STDERR $aryA[0],"|", $aryA[1],"\n";} + $DBchannels[$channel_counter] = "$aryA[0]$US$aryA[1]"; + $channel_counter++; + $rec_count++; + } + $sthA->finish(); -$stmtA = "SELECT channel,extension FROM $live_sip_channels 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; -$rec_count_sip=0; -while ($sthArows > $rec_count_sip) - { - @aryA = $sthA->fetchrow_array; - if($DB){print STDERR $aryA[0],"|", $aryA[1],"\n";} + $stmtA = "SELECT channel,extension FROM $live_sip_channels 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; + $rec_count_sip=0; + while ($sthArows > $rec_count_sip) + { + @aryA = $sthA->fetchrow_array; + if($DB){print STDERR $aryA[0],"|", $aryA[1],"\n";} $DBsips[$sip_counter] = "$aryA[0]$US$aryA[1]"; - if ($aryA[0] =~ /^Zap/) {$zap_client_counter++;} - if ($aryA[0] =~ /^IAX/) {$iax_client_counter++;} - if ($aryA[0] =~ /^Local/) {$local_client_counter++;} - if ($aryA[0] =~ /^SIP/) {$sip_client_counter++;} - $sip_counter++; - $rec_count_sip++; + if ($aryA[0] =~ /^Zap/) {$zap_client_counter++;} + if ($aryA[0] =~ /^IAX/) {$iax_client_counter++;} + if ($aryA[0] =~ /^Local/) {$local_client_counter++;} + if ($aryA[0] =~ /^SIP/) {$sip_client_counter++;} + $sip_counter++; + $rec_count_sip++; + } + $sthA->finish(); + + &get_time_now; + + $stmtU = "UPDATE $server_updater set last_update='$now_date' where server_ip='$server_ip'"; + if($DB){print STDERR "\n|$stmtU|\n";} + $affected_rows = $dbhA->do($stmtU); } -$sthA->finish(); - - &get_time_now; - -$stmtU = "UPDATE $server_updater set last_update='$now_date' where server_ip='$server_ip'"; - if($DB){print STDERR "\n|$stmtU|\n";} -$affected_rows = $dbhA->do($stmtU); - -} @@ -1096,135 +1138,128 @@ $affected_rows = $dbhA->do($stmtU); # I would have used a delete with subselect and saved all of this bloated code ####################################################################### sub validate_parked_channels -{ - -if (!$run_validate_parked_channels_now) { - $parked_counter=0; - @ARchannel=@MT; @ARextension=@MT; @ARparked_time=@MT; @ARparked_time_UNIX=@MT; - $stmtA = "SELECT channel,extension,parked_time,UNIX_TIMESTAMP(parked_time) FROM $parked_channels where server_ip = '$server_ip' order by channel desc, parked_time desc;"; - $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) + if (!$run_validate_parked_channels_now) { - @aryA = $sthA->fetchrow_array; - $PQchannel = $aryA[0]; - $PQextension = $aryA[1]; - $PQparked_time = $aryA[2]; - $PQparked_time_UNIX = $aryA[3]; + $parked_counter=0; + @ARchannel=@MT; @ARextension=@MT; @ARparked_time=@MT; @ARparked_time_UNIX=@MT; + $stmtA = "SELECT channel,extension,parked_time,UNIX_TIMESTAMP(parked_time) FROM $parked_channels where server_ip = '$server_ip' order by channel desc, parked_time desc;"; + $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; + $PQchannel = $aryA[0]; + $PQextension = $aryA[1]; + $PQparked_time = $aryA[2]; + $PQparked_time_UNIX = $aryA[3]; if($DB){print STDERR "\n|$PQchannel|$PQextension|$PQparked_time|$PQparked_time_UNIX|\n";} - $dbhC = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") - or die "Couldn't connect to database: " . DBI->errstr; + $dbhC = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; - $AR=0; - $record_deleted=0; - foreach(@ARchannel) - { - if (@ARchannel[$AR] eq "$PQchannel") + $AR=0; + $record_deleted=0; + foreach(@ARchannel) { - if (@ARparked_time_UNIX[$AR] > $PQparked_time_UNIX) + if (@ARchannel[$AR] eq "$PQchannel") { + if (@ARparked_time_UNIX[$AR] > $PQparked_time_UNIX) + { if($DBX){print "Duplicate parked channel delete: |$PQchannel|$PQparked_time|\n";} - $stmtPQ = "DELETE FROM $parked_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension' and parked_time='$PQparked_time' limit 1"; - if($DB){print STDERR "\n|$stmtPQ|$$DEL_chan_park_counter|$DEL_chan_park_counter|\n\n";} + $stmtPQ = "DELETE FROM $parked_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension' and parked_time='$PQparked_time' limit 1"; + if($DB){print STDERR "\n|$stmtPQ|$$DEL_chan_park_counter|$DEL_chan_park_counter|\n\n";} $affected_rows = $dbhC->do($stmtPQ); - + $DEL_chan_park_counter = "DEL$PQchannel$PQextension"; $$DEL_chan_park_counter=0; - $record_deleted++; + $record_deleted++; + } + } + $AR++; } - - $AR++; - } - - - - if (!$record_deleted) - { - $ARchannel[$rec_count] = $aryA[0]; - $ARextension[$rec_count] = $aryA[1]; - $ARparked_time[$rec_count] = $aryA[2]; - $ARparked_time_UNIX[$rec_count] = $aryA[3]; - - - $dbhB = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") - or die "Couldn't connect to database: " . DBI->errstr; - - - $event_string='LOGGED INTO MYSQL SERVER ON 2 CONNECTIONS TO VALIDATE PARKED CALLS|'; - &event_logger; - - $stmtB = "SELECT count(*) FROM $live_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension';"; - $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; - $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; - $sthBrows=$sthB->rows; - $rec_countB=0; - while ($sthBrows > $rec_countB) + + + + if (!$record_deleted) { - @aryB = $sthB->fetchrow_array; - $PQcount = $aryB[0]; + $ARchannel[$rec_count] = $aryA[0]; + $ARextension[$rec_count] = $aryA[1]; + $ARparked_time[$rec_count] = $aryA[2]; + $ARparked_time_UNIX[$rec_count] = $aryA[3]; + + $dbhB = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") + or die "Couldn't connect to database: " . DBI->errstr; + + $event_string='LOGGED INTO MYSQL SERVER ON 2 CONNECTIONS TO VALIDATE PARKED CALLS|'; + &event_logger; + + $stmtB = "SELECT count(*) FROM $live_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension';"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $sthBrows=$sthB->rows; + $rec_countB=0; + while ($sthBrows > $rec_countB) + { + @aryB = $sthB->fetchrow_array; + $PQcount = $aryB[0]; if($DB){print STDERR "\n|$PQcount|\n";} - $rec_countB++; - } - $sthB->finish(); + $rec_countB++; + } + $sthB->finish(); - if ($PQcount < 1) - { - $DEL_chan_park_counter = "DEL$PQchannel$PQextension"; - $$DEL_chan_park_counter++; + if ($PQcount < 1) + { + $DEL_chan_park_counter = "DEL$PQchannel$PQextension"; + $$DEL_chan_park_counter++; if($DBX){print STDERR "Parked counter down|$$DEL_chan_park_counter|$DEL_chan_park_counter|\n";} - ### if the parked channel doesn't exist 6 times then delete it from table - if ($$DEL_chan_park_counter > 5) - { - if($DBX){print " parked channel delete: |$PQchannel|$PQparked_time|\n";} - $stmtPQ = "DELETE FROM $parked_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension' limit 1"; + ### if the parked channel doesn't exist 6 times then delete it from table + if ($$DEL_chan_park_counter > 5) + { + if($DBX){print " parked channel delete: |$PQchannel|$PQparked_time|\n";} + $stmtPQ = "DELETE FROM $parked_channels where server_ip='$server_ip' and channel='$PQchannel' and extension='$PQextension' limit 1"; if($DB){print STDERR "\n|$stmtPQ|$$DEL_chan_park_counter|$DEL_chan_park_counter|\n\n";} - $affected_rows = $dbhC->do($stmtPQ); + $affected_rows = $dbhC->do($stmtPQ); $ARchannel[$rec_count] = ''; $ARextension[$rec_count] = ''; $ARparked_time[$rec_count] = ''; $ARparked_time_UNIX[$rec_count] = ''; + $$DEL_chan_park_counter=0; + } + } + else + { + $DEL_chan_park_counter = "DEL$PQchannel$PQextension"; $$DEL_chan_park_counter=0; } + + $event_string='CLOSING MYSQL CONNECTIONS OPENED TO VALIDATE PARKED CALLS|'; + &event_logger; + + $dbhB->disconnect(); } - else - { - $DEL_chan_park_counter = "DEL$PQchannel$PQextension"; - $$DEL_chan_park_counter=0; - } + $dbhC->disconnect(); - - $event_string='CLOSING MYSQL CONNECTIONS OPENED TO VALIDATE PARKED CALLS|'; - &event_logger; - - - $dbhB->disconnect(); - + $parked_counter++; + $rec_count++; } - $dbhC->disconnect(); + $sthA->finish(); - $parked_counter++; - $rec_count++; + $run_validate_parked_channels_now=5; # set to run every five times the subroutine runs } - $sthA->finish(); - - $run_validate_parked_channels_now=5; # set to run every five times the subroutine runs + $run_validate_parked_channels_now--; } -$run_validate_parked_channels_now--; -} - @@ -1232,19 +1267,19 @@ $run_validate_parked_channels_now--; ################################################################################ ##### get the current date and time and epoch for logging call lengths and datetimes sub get_time_now -{ -($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) {$Fhour = "0$hour";} -if ($min < 10) {$min = "0$min";} -if ($sec < 10) {$sec = "0$sec";} + { + ($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) {$Fhour = "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"; -} + $now_date_epoch = time(); + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + } @@ -1253,13 +1288,13 @@ $now_date = "$year-$mon-$mday $hour:$min:$sec"; ################################################################################ ##### open the log file for writing ### sub event_logger -{ -if ($SYSLOG) { - open(Lout, ">>$UPLOGfile") - || die "Can't open $UPLOGfile: $!\n"; - print Lout "$now_date|$event_string|\n"; - close(Lout); + if ($SYSLOG) + { + open(Lout, ">>$UPLOGfile") + || die "Can't open $UPLOGfile: $!\n"; + print Lout "$now_date|$event_string|\n"; + close(Lout); + } + $event_string=''; } -$event_string=''; -} 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 275e8c40..a04e75b9 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -99,7 +99,12 @@ recording_web_link ENUM('SERVER_IP','ALT_IP') default 'SERVER_IP', alt_server_ip VARCHAR(100) default '', active_asterisk_server ENUM('Y','N') default 'Y', generate_vicidial_conf ENUM('Y','N') default 'Y', -rebuild_conf_files ENUM('Y','N') default 'Y' +rebuild_conf_files ENUM('Y','N') default 'Y', +outbound_calls_per_second SMALLINT(3) UNSIGNED default '20', +sysload INT(6) NOT NULL default '0', +channels_total SMALLINT(4) UNSIGNED NOT NULL default '0', +cpu_idle_percent SMALLINT(3) UNSIGNED NOT NULL default '0', +disk_usage VARCHAR(255) default '1' ); CREATE UNIQUE INDEX server_id on servers (server_id); @@ -485,7 +490,10 @@ modify_inbound_dids ENUM('1','0') default '0', delete_inbound_dids ENUM('1','0') default '0', active ENUM('Y','N') default 'Y', alert_enabled ENUM('1','0') default '0', -download_lists ENUM('1','0') default '0' +download_lists ENUM('1','0') default '0', +agent_shift_enforcement_override ENUM('DISABLED','OFF','START','ALL') default 'DISABLED', +manager_shift_enforcement_override ENUM('0','1') default '0', +shift_override_flag ENUM('0','1') default '0' ); @@ -509,7 +517,8 @@ allowed_campaigns TEXT, qc_allowed_campaigns TEXT, qc_allowed_inbound_groups TEXT, group_shifts TEXT, -forced_timeclock_login ENUM('Y','N','ADMIN_EXEMPT') default 'N' +forced_timeclock_login ENUM('Y','N','ADMIN_EXEMPT') default 'N', +shift_enforcement ENUM('OFF','START','ALL') default 'OFF' ); CREATE TABLE vicidial_campaigns ( @@ -1058,7 +1067,8 @@ vtiger_login VARCHAR(50), vtiger_pass VARCHAR(50), vtiger_url VARCHAR(255), qc_features_active ENUM('1','0') default '0', -outbound_autodial_active ENUM('1','0') default '1' +outbound_autodial_active ENUM('1','0') default '1', +outbound_calls_per_second SMALLINT(3) UNSIGNED default '40' ); CREATE TABLE vicidial_campaigns_list_mix ( @@ -1268,7 +1278,7 @@ event_date DATETIME NOT NULL, user VARCHAR(20) NOT NULL, ip_address VARCHAR(15) NOT NULL, event_section VARCHAR(30) NOT NULL, -event_type ENUM('ADD','COPY','LOAD','RESET','MODIFY','DELETE','SEARCH','LOGIN','LOGOUT','CLEAR','OTHER') default 'OTHER', +event_type ENUM('ADD','COPY','LOAD','RESET','MODIFY','DELETE','SEARCH','LOGIN','LOGOUT','CLEAR','OVERRIDE','OTHER') default 'OTHER', record_id VARCHAR(50) NOT NULL, event_code VARCHAR(255) NOT NULL, event_sql TEXT, @@ -1520,7 +1530,7 @@ CREATE INDEX phone_number on vicidial_closer_log (phone_number); CREATE INDEX date_user on vicidial_closer_log (call_date,user); CREATE INDEX comment_a on live_inbound_log (comment_a); -UPDATE system_settings SET db_schema_version='1132'; +UPDATE system_settings SET db_schema_version='1133'; GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; diff --git a/agc_2-X/trunk/extras/upgrade_2.0.5.sql b/agc_2-X/trunk/extras/upgrade_2.0.5.sql index 15425a2c..7551d900 100644 --- a/agc_2-X/trunk/extras/upgrade_2.0.5.sql +++ b/agc_2-X/trunk/extras/upgrade_2.0.5.sql @@ -763,3 +763,21 @@ ALTER TABLE vicidial_campaigns MODIFY three_way_call_cid ENUM('CAMPAIGN','CUSTOM ALTER TABLE vicidial_inbound_groups ADD default_group_alias VARCHAR(30) default ''; UPDATE system_settings SET db_schema_version='1132'; + +ALTER TABLE servers ADD outbound_calls_per_second SMALLINT(3) UNSIGNED default '20'; +ALTER TABLE servers ADD sysload INT(6) NOT NULL default '0'; +ALTER TABLE servers ADD channels_total SMALLINT(4) UNSIGNED NOT NULL default '0'; +ALTER TABLE servers ADD cpu_idle_percent SMALLINT(3) UNSIGNED NOT NULL default '0'; +ALTER TABLE servers ADD disk_usage VARCHAR(255) default '1'; + +ALTER TABLE system_settings ADD outbound_calls_per_second SMALLINT(3) UNSIGNED default '40'; + +ALTER TABLE vicidial_user_groups ADD shift_enforcement ENUM('OFF','START','ALL') default 'OFF'; + +ALTER TABLE vicidial_users ADD agent_shift_enforcement_override ENUM('DISABLED','OFF','START','ALL') default 'DISABLED'; +ALTER TABLE vicidial_users ADD manager_shift_enforcement_override ENUM('0','1') default '0'; +ALTER TABLE vicidial_users ADD shift_override_flag ENUM('0','1') default '0'; + +ALTER TABLE vicidial_admin_log MODIFY event_type ENUM('ADD','COPY','LOAD','RESET','MODIFY','DELETE','SEARCH','LOGIN','LOGOUT','CLEAR','OVERRIDE','OTHER') default 'OTHER'; + +UPDATE system_settings SET db_schema_version='1133'; diff --git a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt index 3bfc8ad6..1fc01b55 100644 --- a/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt +++ b/agc_2-X/trunk/translations/raw_translation_files/TO_BE_TRANSLATED_2.0.5.txt @@ -507,6 +507,22 @@ Group Alias Allowed|| Default Group Alias|| AGENT_CHOOSE allows the agent to choose which callerID to use for 3-way calls from a list of choices.|| you cannot use reserved words in group aliases|| +Agent Shift Enforcement Override|| +Manager Shift Enforcement Override|| +Shift Enforcement|| +Max Calls per Second|| +Max FILL Calls per Second|| +This setting will override whatever the users user group has set for Shift Enforcement. DISABLED will use the user group setting. OFF will not enforce shifts at all. START will only enforce the login time but will not affect an agent that is running over their shift time if they are already logged in. ALL will enforce shift start time and will log an agent out after they run over the end of their shift time. Default is DISABLED.|| +This setting if set to 1 will allow a manager to enter their user and password on an agent screen to override the shift restrictions on an agent session if the agent is trying to log in outside of their shift. Default is 0.|| +This setting allows you to restrict agent logins based upon the shifts that are selected below. OFF will not enforce shifts at all. START will only enforce the login time but will not affect an agent that is running over their shift time if they are already logged in. ALL will enforce shift start time and will log an agent out after they run over the end of their shift time. Default is OFF.|| +This setting determines the maximum number of calls that can be placed by the outbound auto-dialing script on this server per second. Must be from 1 to 100. Default is 20.|| +This setting determines the maximum number of calls that can be placed by the auto-FILL outbound auto-dialing script on for all servers, per second. Must be from 1 to 200. Default is 40.|| +System Load|| +Live Channels|| +Disk Usage|| +These two statistics show the loadavg of a system times 100 and the CPU usage percentage of the server and is updated every minute. The loadavg should on average be below 100 multiplied by the number of CPU cores your system has, for optimal performance. The CPU usage percentage should stay below 50 for optimal performance.|| +This field shows the current number of Asterisk channels that are live on the system right now. It is important to note that the number of Asterisk channels is usually much higher than the number of actual calls on a system. This field is updated once every minute.|| +This field will show the disk usage for every partition on this server. This field is updated once every minute.|| ############################################################ CLIENT @@ -550,6 +566,10 @@ SELECT A GROUP ALIAS|| Group Alias Selection|| Click Here to Choose a Group Alias|| Group Alias|| +ERROR: There are no Shifts enabled for your user group|| +ERROR: You are not allowed to log in outside of your shift|| +MANAGER OVERRIDE|| +Your Shift is over or has changed, you have been logged out of your session|| ############################################################ MANAGER Manual diff --git a/agc_2-X/trunk/www/agc/conf_exten_check.php b/agc_2-X/trunk/www/agc/conf_exten_check.php index c224d541..dd338763 100644 --- a/agc_2-X/trunk/www/agc/conf_exten_check.php +++ b/agc_2-X/trunk/www/agc/conf_exten_check.php @@ -42,12 +42,13 @@ # 81104-1409 - Added multi-retry for some vicidial_live_agents table MySQL queries # 90102-1402 - Added check for system and database time synchronization # 90120-1720 - Added compatibility for API pause/resume and dial a number +# 90307-1855 - Added shift enforcement to send logout flag if outside of shift hours # -$version = '2.0.4-17'; -$build = '90120-1720'; +$version = '2.0.5-18'; +$build = '90307-1855'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=14; +$mysql_log_count=17; $one_mysql_log=0; require("dbconnect.php"); @@ -318,12 +319,94 @@ echo " $time_diff = ($server_epoch - $db_epoch); $web_diff = ($db_epoch - $web_epoch); + + ##### grab the shift information the agent + $stmt="SELECT user_group,agent_shift_enforcement_override from vicidial_users where user='$user';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03015',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $VU_user_group = $row[0]; + $VU_agent_shift_enforcement_override = $row[1]; + + ### Gather timeclock and shift enforcement restriction settings + $stmt="SELECT shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'03016',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $shift_enforcement = $row[0]; + $LOGgroup_shiftsSQL = eregi_replace(' ','',$row[1]); + $LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL); + $LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')"; + + ### CHECK TO SEE IF AGENT IS WITHIN THEIR SHIFT IF RESTRICTED, IF NOT, OUTPUT ERROR + $Ashift_logout=0; + if ( ( (ereg("ALL",$shift_enforcement)) and (!ereg("OFF|START",$VU_agent_shift_enforcement_override)) ) or (ereg("ALL",$VU_agent_shift_enforcement_override)) ) + { + $shift_ok=0; + if (strlen($LOGgroup_shiftsSQL) < 3) + {$Ashift_logout++;} + else + { + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'3017',$user,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ($shift_ok < 1) + {$Ashift_logout++;} + } + } + + if ( ( ($time_diff > 8) or ($time_diff < -8) or ($web_diff > 8) or ($web_diff < -8) ) and (eregi("0$",$StarTtime)) ) {$Alogin='TIME_SYNC';} if ($Acount < 1) {$Alogin='DEAD_VLA';} if ($AexternalDEAD > 0) {$Alogin='DEAD_EXTERNAL';} + if ($Ashift_logout > 0) + {$Alogin='SHIFT_LOGOUT';} echo 'DateTime: ' . $NOW_TIME . '|UnixTime: ' . $StarTtime . '|Logged-in: ' . $Alogin . '|CampCalls: ' . $RingCalls . '|Status: ' . $Astatus . '|DiaLCalls: ' . $DiaLCalls . '|APIHanguP: ' . $external_hangup . '|APIStatuS: ' . $external_status . '|APIPausE: ' . $external_pause . '|APIDiaL: ' . $external_dial . "|\n"; diff --git a/agc_2-X/trunk/www/agc/vdc_db_query.php b/agc_2-X/trunk/www/agc/vdc_db_query.php index c6c21ccd..3452ae0f 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -189,12 +189,13 @@ # 90128-0231 - Added vendor_lead_code to manual dial lead lookup # 90304-1335 - Added support for group aliases and agent-specific variables for campaigns and in-groups # 90305-1041 - Added agent_dialed_number and type for user_call_log feature +# 90307-1735 - Added Shift enforcement and manager override features # -$version = '2.0.5-102'; -$build = '90305-1041'; +$version = '2.0.5-103'; +$build = '90307-1735'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=192; +$mysql_log_count=193; $one_mysql_log=0; require("dbconnect.php"); @@ -470,7 +471,7 @@ echo " ### specific agent on the login screen ################################################################################ if ($ACTION == 'LogiNCamPaigns') -{ + { if ( (strlen($user)<1) ) { echo "\n"; - echo "\n"; - - $o=0; - while ($camps_to_print > $o) - { - $rowx=mysql_fetch_row($rslt); - echo "\n"; - $o++; - } - echo "\n"; + $VDdisplayMESSAGE = "ERROR: There are no Shifts enabled for your user group\n"; + $VDloginDISPLAY=1; } else { - echo "\n"; + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00193',$user,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) ) + { + $VDdisplayMESSAGE = "ERROR: You are not allowed to log in outside of your shift\n"; + $VDloginDISPLAY=1; + } + } + if ($VDloginDISPLAY > 0) + { + $loginDATE = date("Ymd"); + $VDdisplayMESSAGE.= "

MANAGER OVERRIDE:
\n"; + $VDdisplayMESSAGE.= "
\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "Manager Login:
\n"; + $VDdisplayMESSAGE.= "Manager Password:
\n"; + $VDdisplayMESSAGE.= "




\n"; + echo "$VDdisplayMESSAGE"; + exit; } - exit; } -} + + if ($show_campaign_list > 0) + { + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00006',$user,$server_ip,$session_name,$one_mysql_log);} + $camps_to_print = mysql_num_rows($rslt); + + echo "\n"; + } + else + { + echo "\n"; + } + exit; + } diff --git a/agc_2-X/trunk/www/agc/vicidial.php b/agc_2-X/trunk/www/agc/vicidial.php index 38d18ac9..4a7f7897 100644 --- a/agc_2-X/trunk/www/agc/vicidial.php +++ b/agc_2-X/trunk/www/agc/vicidial.php @@ -221,12 +221,13 @@ # 90303-1145 - Fixed rare manual dial live hangup bug # 90304-1333 - Added user-specific web vars option # 90305-0917 - Added prefix-choice and group-alias options for calls coming from API +# 90307-1736 - Added Shift enforcement and manager override features # -$version = '2.0.5-200'; -$build = '90305-0917'; +$version = '2.0.5-201'; +$build = '90307-1736'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=55; +$mysql_log_count=60; $one_mysql_log=0; require("dbconnect.php"); @@ -245,6 +246,8 @@ if (isset($_GET["VD_campaign"])) {$VD_campaign=$_GET["VD_campaign elseif (isset($_POST["VD_campaign"])) {$VD_campaign=$_POST["VD_campaign"];} if (isset($_GET["relogin"])) {$relogin=$_GET["relogin"];} elseif (isset($_POST["relogin"])) {$relogin=$_POST["relogin"];} +if (isset($_GET["MGR_override"])) {$MGR_override=$_GET["MGR_override"];} + elseif (isset($_POST["MGR_override"])) {$MGR_override=$_POST["MGR_override"];} if (!isset($phone_login)) { if (isset($_GET["pl"])) {$phone_login=$_GET["pl"];} @@ -288,6 +291,7 @@ $StarTtimE = date("U"); $NOW_TIME = date("Y-m-d H:i:s"); $tsNOW_TIME = date("YmdHis"); $FILE_TIME = date("Ymd-His"); +$loginDATE = date("Ymd"); $CIDdate = date("ymdHis"); $month_old = mktime(11, 0, 0, date("m"), date("d")-2, date("Y")); $past_month_date = date("Y-m-d H:i:s",$month_old); @@ -445,6 +449,41 @@ if ($relogin == 'YES') } } +### code for manager override of shift restrictions +if ($MGR_override > 0) + { + if (isset($_GET["MGR_login$loginDATE"])) {$MGR_login=$_GET["MGR_login$loginDATE"];} + elseif (isset($_POST["MGR_login$loginDATE"])) {$MGR_login=$_POST["MGR_login$loginDATE"];} + if (isset($_GET["MGR_pass$loginDATE"])) {$MGR_pass=$_GET["MGR_pass$loginDATE"];} + elseif (isset($_POST["MGR_pass$loginDATE"])) {$MGR_pass=$_POST["MGR_pass$loginDATE"];} + + $stmt="SELECT count(*) from vicidial_users where user='$MGR_login' and pass='$MGR_pass' and manager_shift_enforcement_override='1' and active='Y';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01058',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $row=mysql_fetch_row($rslt); + $MGR_auth=$row[0]; + + if($MGR_auth>0) + { + $stmt="UPDATE vicidial_users SET shift_override_flag='1' where user='$VD_login' and pass='$VD_pass';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01059',$VD_login,$server_ip,$session_name,$one_mysql_log);} + print "\n"; + + ### Add a record to the vicidial_admin_log + $SQL_log = "$stmt|"; + $SQL_log = ereg_replace(';','',$SQL_log); + $SQL_log = addslashes($SQL_log); + $stmt="INSERT INTO vicidial_admin_log set event_date='$NOW_TIME', user='$MGR_login', ip_address='$ip', event_section='AGENT', event_type='OVERRIDE', record_id='$VD_login', event_code='MANAGER OVERRIDE OF AGENT SHIFT ENFORCEMENT', event_sql=\"$SQL_log\", event_notes='user: $VD_login';"; + if ($DB) {echo "|$stmt|\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01060',$VD_login,$server_ip,$session_name,$one_mysql_log);} + } + } + + $stmt="SELECT campaign_id,campaign_name from vicidial_campaigns where active='Y' $LOGallowed_campaignsSQL order by campaign_id"; if ($non_latin > 0) {$rslt=mysql_query("SET NAMES 'UTF8'");} $rslt=mysql_query($stmt, $link); @@ -715,35 +754,42 @@ $VDloginDISPLAY=0; $login=strtoupper($VD_login); $password=strtoupper($VD_pass); ##### grab the full name of the agent - $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled from vicidial_users where user='$VD_login' and pass='$VD_pass'"; + $stmt="SELECT full_name,user_level,hotkeys_active,agent_choose_ingroups,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,closer_default_blended,user_group,vicidial_recording_override,alter_custphone_override,alert_enabled,agent_shift_enforcement_override,shift_override_flag from vicidial_users where user='$VD_login' and pass='$VD_pass'"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01007',$VD_login,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); - $LOGfullname=$row[0]; - $user_level=$row[1]; - $VU_hotkeys_active=$row[2]; - $VU_agent_choose_ingroups=$row[3]; - $VU_scheduled_callbacks=$row[4]; - $agentonly_callbacks=$row[5]; - $agentcall_manual=$row[6]; - $VU_vicidial_recording=$row[7]; - $VU_vicidial_transfers=$row[8]; - $VU_closer_default_blended=$row[9]; - $VU_user_group=$row[10]; - $VU_vicidial_recording_override=$row[11]; - $VU_alter_custphone_override=$row[12]; - $VU_alert_enabled=$row[13]; + $LOGfullname = $row[0]; + $user_level = $row[1]; + $VU_hotkeys_active = $row[2]; + $VU_agent_choose_ingroups = $row[3]; + $VU_scheduled_callbacks = $row[4]; + $agentonly_callbacks = $row[5]; + $agentcall_manual = $row[6]; + $VU_vicidial_recording = $row[7]; + $VU_vicidial_transfers = $row[8]; + $VU_closer_default_blended = $row[9]; + $VU_user_group = $row[10]; + $VU_vicidial_recording_override = $row[11]; + $VU_alter_custphone_override = $row[12]; + $VU_alert_enabled = $row[13]; + $VU_agent_shift_enforcement_override = $row[14]; + $VU_shift_override_flag = $row[15]; if ($VU_alert_enabled > 0) {$VU_alert_enabled = 'ON';} else {$VU_alert_enabled = 'OFF';} - ### BEGIN - CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR - $stmt="SELECT forced_timeclock_login from vicidial_user_groups where user_group='$VU_user_group';"; + ### Gather timeclock and shift enforcement restriction settings + $stmt="SELECT forced_timeclock_login,shift_enforcement,group_shifts from vicidial_user_groups where user_group='$VU_user_group';"; $rslt=mysql_query($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01052',$VD_login,$server_ip,$session_name,$one_mysql_log);} $row=mysql_fetch_row($rslt); - $forced_timeclock_login = $row[0]; + $forced_timeclock_login = $row[0]; + $shift_enforcement = $row[1]; + $LOGgroup_shiftsSQL = eregi_replace(' ','',$row[2]); + $LOGgroup_shiftsSQL = eregi_replace(' ',"','",$LOGgroup_shiftsSQL); + $LOGgroup_shiftsSQL = "shift_id IN('$LOGgroup_shiftsSQL')"; + ### BEGIN - CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR if ( (ereg('Y',$forced_timeclock_login)) or ( (ereg('ADMIN_EXEMPT',$forced_timeclock_login)) and ($VU_user_level < 8) ) ) { $last_agent_event=''; @@ -777,6 +823,92 @@ $VDloginDISPLAY=0; } ### END - CHECK TO SEE IF AGENT IS LOGGED IN TO TIMECLOCK, IF NOT, OUTPUT ERROR + ### BEGIN - CHECK TO SEE IF SHIFT ENFORCEMENT IS ENABLED AND AGENT IS OUTSIDE OF THEIR SHIFTS, IF SO, OUTPUT ERROR + if ( ( (ereg("START|ALL",$shift_enforcement)) and (!ereg("OFF",$VU_agent_shift_enforcement_override)) ) or (ereg("START|ALL",$VU_agent_shift_enforcement_override)) ) + { + $shift_ok=0; + if ( (strlen($LOGgroup_shiftsSQL) < 3) and ($VU_shift_override_flag < 1) ) + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "ERROR: There are no Shifts enabled for your user group
"; + } + else + { + $HHMM = date("Hi"); + $wday = date("w"); + + $stmt="SELECT shift_id,shift_start_time,shift_length,shift_weekdays from vicidial_shifts where $LOGgroup_shiftsSQL order by shift_id"; + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01056',$user,$server_ip,$session_name,$one_mysql_log);} + $shifts_to_print = mysql_num_rows($rslt); + + $o=0; + while ( ($shifts_to_print > $o) and ($shift_ok < 1) ) + { + $rowx=mysql_fetch_row($rslt); + $shift_id = $rowx[0]; + $shift_start_time = $rowx[1]; + $shift_length = $rowx[2]; + $shift_weekdays = $rowx[3]; + + if (eregi("$wday",$shift_weekdays)) + { + $HHshift_length = substr($shift_length,0,2); + $MMshift_length = substr($shift_length,3,2); + $HHshift_start_time = substr($shift_start_time,0,2); + $MMshift_start_time = substr($shift_start_time,2,2); + $HHshift_end_time = ($HHshift_length + $HHshift_start_time); + $MMshift_end_time = ($MMshift_length + $MMshift_start_time); + if ($MMshift_end_time > 59) + { + $MMshift_end_time = ($MMshift_end_time - 60); + $HHshift_end_time++; + } + if ($HHshift_end_time > 23) + {$HHshift_end_time = ($HHshift_end_time - 24);} + $HHshift_end_time = sprintf("%02s", $HHshift_end_time); + $MMshift_end_time = sprintf("%02s", $MMshift_end_time); + $shift_end_time = "$HHshift_end_time$MMshift_end_time"; + + if ( + ( ($HHMM >= $shift_start_time) and ($HHMM < $shift_end_time) ) or + ( ($HHMM < $shift_start_time) and ($HHMM < $shift_end_time) and ($shift_end_time <= $shift_start_time) ) or + ( ($HHMM >= $shift_start_time) and ($HHMM >= $shift_end_time) and ($shift_end_time <= $shift_start_time) ) + ) + {$shift_ok++;} + } + $o++; + } + + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) ) + { + $VDloginDISPLAY=1; + $VDdisplayMESSAGE = "ERROR: You are not allowed to log in outside of your shift
"; + } + } + if ( ($shift_ok < 1) and ($VU_shift_override_flag < 1) and ($VDloginDISPLAY > 0) ) + { + $VDdisplayMESSAGE.= "

MANAGER OVERRIDE:
\n"; + $VDdisplayMESSAGE.= "
\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "\n"; + $VDdisplayMESSAGE.= "Manager Login:
\n"; + $VDdisplayMESSAGE.= "Manager Password:
\n"; + $VDdisplayMESSAGE.= "
\n"; + } + } + ### END - CHECK TO SEE IF SHIFT ENFORCEMENT IS ENABLED AND AGENT IS OUTSIDE OF THEIR SHIFTS, IF SO, OUTPUT ERROR + + + + + + if ($WeBRooTWritablE > 0) { @@ -1766,6 +1898,12 @@ else $agent_log_id = mysql_insert_id($link); print "\n"; + $stmt="UPDATE vicidial_users SET shift_override_flag='0' where user='$VD_login' and shift_override_flag='1';"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_query($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'01057',$VD_login,$server_ip,$session_name,$one_mysql_log);} + $VUaffected_rows = mysql_affected_rows($link); + $S='*'; $D_s_ip = explode('.', $server_ip); if (strlen($D_s_ip[0])<2) {$D_s_ip[0] = "0$D_s_ip[0]";} @@ -2245,6 +2383,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} var VtigeRurl = ''; var VtigeREnableD = ''; var alert_enabled = '' + var shift_logout_flag = 0; var DiaLControl_auto_HTML = "\"\"Resume\""; var DiaLControl_auto_HTML_ready = "\"\"Resume\""; var DiaLControl_auto_HTML_OFF = "\"\"Resume\""; @@ -2838,6 +2977,10 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} { showDiv('SysteMDisablEBoX'); } + if (AGLogiN == 'SHIFT_LOGOUT') + { + shift_logout_flag=1; + } } var VLAStatuS_array = check_time_array[4].split("Status: "); var VLAStatuS = VLAStatuS_array[1]; @@ -6085,41 +6228,48 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} AgentDispoing = 0; - if (wrapup_waiting == 0) + if (shift_logout_flag < 1) { - if (document.vicidial_form.DispoSelectStop.checked==true) + if (wrapup_waiting == 0) { - if (auto_dial_level != '0') + if (document.vicidial_form.DispoSelectStop.checked==true) { - AutoDialWaiting = 0; - AutoDial_ReSume_PauSe("VDADpause"); - // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; - } - VICIDiaL_pause_calling = 1; - if (dispo_check_all_pause != '1') - { - document.vicidial_form.DispoSelectStop.checked=false; - } - } - else - { - if (auto_dial_level != '0') - { - AutoDialWaiting = 1; - AutoDial_ReSume_PauSe("VDADready","NEW_ID"); - // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; + if (auto_dial_level != '0') + { + AutoDialWaiting = 0; + AutoDial_ReSume_PauSe("VDADpause"); + // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML; + } + VICIDiaL_pause_calling = 1; + if (dispo_check_all_pause != '1') + { + document.vicidial_form.DispoSelectStop.checked=false; + } } else { - // trigger HotKeys manual dial automatically go to next lead - if (manual_auto_hotkey == '1') + if (auto_dial_level != '0') { - manual_auto_hotkey = 0; - ManualDialNext('','','','','','0'); + AutoDialWaiting = 1; + AutoDial_ReSume_PauSe("VDADready","NEW_ID"); + // document.getElementById("DiaLControl").innerHTML = DiaLControl_auto_HTML_ready; + } + else + { + // trigger HotKeys manual dial automatically go to next lead + if (manual_auto_hotkey == '1') + { + manual_auto_hotkey = 0; + ManualDialNext('','','','','','0'); + } } } } } + else + { + LogouT('SHIFT'); + } } } @@ -6457,7 +6607,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} { if (logout_stop_timeouts < 1) { - LogouT(); + LogouT('CLOSE'); alert("PLEASE CLICK THE LOGOUT LINK TO LOG OUT NEXT TIME.\n"); } } @@ -6465,7 +6615,7 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} // ################################################################################ // Log the user out of the system, if active call or active dial is occuring, don't let them. - function LogouT() + function LogouT(tempreason) { if (MD_channel_look==1) {alert("You cannot log out during a Dial attempt. \nWait 50 seconds for the dial to fail out if it is not answered");} @@ -6514,8 +6664,11 @@ if ($enable_fast_refresh < 1) {echo "\tvar refresh_interval = 1000;\n";} hideDiv('MainPanel'); showDiv('LogouTBox'); + var logout_content=''; + if (tempreason=='SHIFT') + {logout_content='Your Shift is over or has changed, you have been logged out of your session

';} - document.getElementById("LogouTBoxLink").innerHTML = "CLICK HERE TO LOG IN AGAIN\n"; + document.getElementById("LogouTBoxLink").innerHTML = logout_content + "CLICK HERE TO LOG IN AGAIN\n"; logout_stop_timeouts = 1; @@ -7853,7 +8006,7 @@ echo "\n";     0) {echo "GROUPS     \n";} ?> -LOGOUT\n"; ?> +LOGOUT\n"; ?> @@ -8097,7 +8250,7 @@ Your Status:
Calls Dialing: - height=500>\n"; echo "\n"; echo "\n"; + + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; echo "\n"; + + echo "\n"; + } echo "\n"; echo "
Your session has been disabled
LOGOUT

Go Back + height=500>
Your session has been disabled
LOGOUT

Go Back
diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 80e89b96..f6623285 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -944,6 +944,14 @@ if (isset($_GET["agent_allow_group_alias"])) {$agent_allow_group_alias=$_GET[" elseif (isset($_POST["agent_allow_group_alias"])) {$agent_allow_group_alias=$_POST["agent_allow_group_alias"];} if (isset($_GET["default_group_alias"])) {$default_group_alias=$_GET["default_group_alias"];} elseif (isset($_POST["default_group_alias"])) {$default_group_alias=$_POST["default_group_alias"];} +if (isset($_GET["outbound_calls_per_second"])) {$outbound_calls_per_second=$_GET["outbound_calls_per_second"];} + elseif (isset($_POST["outbound_calls_per_second"])) {$outbound_calls_per_second=$_POST["outbound_calls_per_second"];} +if (isset($_GET["shift_enforcement"])) {$shift_enforcement=$_GET["shift_enforcement"];} + elseif (isset($_POST["shift_enforcement"])) {$shift_enforcement=$_POST["shift_enforcement"];} +if (isset($_GET["agent_shift_enforcement_override"])) {$agent_shift_enforcement_override=$_GET["agent_shift_enforcement_override"];} + elseif (isset($_POST["agent_shift_enforcement_override"])) {$agent_shift_enforcement_override=$_POST["agent_shift_enforcement_override"];} +if (isset($_GET["manager_shift_enforcement_override"])) {$manager_shift_enforcement_override=$_GET["manager_shift_enforcement_override"];} + elseif (isset($_POST["manager_shift_enforcement_override"])) {$manager_shift_enforcement_override=$_POST["manager_shift_enforcement_override"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} if (isset($lead_filter_id)) {$lead_filter_id = strtoupper($lead_filter_id);} @@ -1124,6 +1132,8 @@ $qc_features_active = ereg_replace("[^0-9]","",$qc_features_active); $outbound_autodial_active = ereg_replace("[^0-9]","",$outbound_autodial_active); $download_lists = ereg_replace("[^0-9]","",$download_lists); $caller_id_number = ereg_replace("[^0-9]","",$caller_id_number); +$outbound_calls_per_second = ereg_replace("[^0-9]","",$outbound_calls_per_second); +$manager_shift_enforcement_override = ereg_replace("[^0-9]","",$manager_shift_enforcement_override); ### DIGITS and COLONS $shift_length = ereg_replace("[^\:0-9]","",$shift_length); @@ -1207,6 +1217,8 @@ $survey_ni_status = ereg_replace("[^0-9a-zA-Z]","",$survey_ni_status); $qc_get_record_launch = ereg_replace("[^0-9a-zA-Z]","",$qc_get_record_launch); $agent_pause_codes_active = ereg_replace("[^0-9a-zA-Z]","",$agent_pause_codes_active); $three_way_dial_prefix = ereg_replace("[^0-9a-zA-Z]","",$three_way_dial_prefix); +$shift_enforcement = ereg_replace("[^0-9a-zA-Z]","",$shift_enforcement); +$agent_shift_enforcement_override = ereg_replace("[^0-9a-zA-Z]","",$agent_shift_enforcement_override); ### DIGITS and Dots $server_ip = ereg_replace("[^\.0-9]","",$server_ip); @@ -1624,11 +1636,12 @@ $dialplan_entry = ereg_replace(";","",$dialplan_entry); # 90302-2046 - Changed Section heading to be on the left side of the screen # 90303-0631 - Added web vars to agent campaign and in-group settings # 90303-2047 - Added group aliases and default group aliases +# 90306-1214 - Added shift enforcement and server/system calls per second options # # 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 -$admin_version = '2.0.5-168'; -$build = '90303-2047'; +$admin_version = '2.0.5-169'; +$build = '90306-1214'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -1731,6 +1744,7 @@ $browser = getenv("HTTP_USER_AGENT"); $LOGview_reports =$row[43]; $LOGmodify_dids =$row[56]; $LOGdelete_dids =$row[57]; + $LOGmanager_shift_enforcement_override=$row[61]; $stmt="SELECT allowed_campaigns from vicidial_user_groups where user_group='$LOGuser_group';"; $rslt=mysql_query($stmt, $link); @@ -2613,6 +2627,11 @@ if ($SSoutbound_autodial_active > 0)
VICIDIAL Recording Override - This option will override whatever the option is in the campaign for recording. DISABLED will not override the campaign recording setting. NEVER will disable recording on the client. ONDEMAND is the default and allows the agent to start and stop recording as needed. ALLCALLS will start recording on the client whenever a call is sent to an agent. ALLFORCE will start recording on the client whenever a call is sent to an agent giving the agent no option to stop recording. For ALLCALLS and ALLFORCE there is an option to use the Recording Delay to cut down on very short recordings and recude system load. +
+ +
+Agent Shift Enforcement Override - This setting will override whatever the users user group has set for Shift Enforcement. DISABLED will use the user group setting. OFF will not enforce shifts at all. START will only enforce the login time but will not affect an agent that is running over their shift time if they are already logged in. ALL will enforce shift start time and will log an agent out after they run over the end of their shift time. Default is DISABLED. +

@@ -2806,6 +2825,13 @@ if ($SSqc_features_active > 0)
Agent API Access - This option allows the account to be used with the vicidial agent API commands. +
+
+
+Manager Shift Enforcement Override - This setting if set to 1 will allow a manager to enter their user and password on an agent screen to override the shift restrictions on an agent session if the agent is trying to log in outside of their shift. Default is 0. + + + @@ -3903,6 +3929,11 @@ if ($SSoutbound_autodial_active > 0)
Force Timeclock Login - This option allows you to not let an agent log in to the VICIDIAL agent interface if they have not logged into the timeclock. Default is N. There is an option to exempt admin users, levels 8 and 9. +
+
+
+Shift Enforcement - This setting allows you to restrict agent logins based upon the shifts that are selected below. OFF will not enforce shifts at all. START will only enforce the login time but will not affect an agent that is running over their shift time if they are already logged in. ALL will enforce shift start time and will log an agent out after they run over the end of their shift time. Default is OFF. +

@@ -4515,6 +4546,21 @@ if ($SSoutbound_autodial_active > 0)
Active - Set whether the Asterisk server is active or inactive. +
+
+
+System Load - These two statistics show the loadavg of a system times 100 and the CPU usage percentage of the server and is updated every minute. The loadavg should on average be below 100 multiplied by the number of CPU cores your system has, for optimal performance. The CPU usage percentage should stay below 50 for optimal performance. + +
+
+
+Live Channels - This field shows the current number of Asterisk channels that are live on the system right now. It is important to note that the number of Asterisk channels is usually much higher than the number of actual calls on a system. This field is updated once every minute. + +
+
+
+Disk Usage - This field will show the disk usage for every partition on this server. This field is updated once every minute. +

@@ -4525,6 +4571,11 @@ if ($SSoutbound_autodial_active > 0)
Max VICIDIAL Trunks - This field will determine the maximum number of lines that the VICIDIAL auto-dialer will attempt to call on this server. If you want to dedicate two full PRI T1s to VICIDIALing on a server then you would set this to 46. Default is 96. +
+
+
+Max Calls per Second - This setting determines the maximum number of calls that can be placed by the outbound auto-dialing script on this server per second. Must be from 1 to 100. Default is 20. +

@@ -4828,18 +4879,26 @@ AU_SPAC 000 000 000 - Australia space separated phone number
IT_DASH 0000-000-000 - Italy dash separated phone number
FR_SPAC 00 00 00 00 00 - France space separated phone number
+

Agent interface API Access Active - This option allows you to enable or disable the agent interface API. Default is 0. +

QC Features Active - This option allows you to enable or disable the QC or Quality Control features. Default is 0 for inactive. +

Outbound Auto-Dial Active - This option allows you to enable or disable outbound auto-dialing within VICIDIAL, setting this field to 0 will remove the LISTS and FILTERS sections and many fields from the Campaign Modification screens. Manual entry dialing will still be allowable from within the agent screen, but no list dialing will be possible. Default is 1 for active. +
+
+
+Max FILL Calls per Second - This setting determines the maximum number of calls that can be placed by the auto-FILL outbound auto-dialing script on for all servers, per second. Must be from 1 to 200. Default is 40. +

@@ -5402,7 +5461,7 @@ function user_submit() } ### Javascript for shift end-time calculation and display -if ( ($ADD==131111111) or ($ADD==331111111) ) +if ( ($ADD==131111111) or ($ADD==331111111) or ($ADD==431111111) ) { ?> function shift_time() @@ -5411,6 +5470,21 @@ function shift_time() var end_time = document.getElementById("shift_end_time"); var length = document.getElementById("shift_length"); + var st_value = start_time.value; + var et_value = end_time.value; + while (st_value.length < 4) {st_value = "0" + st_value;} + while (et_value.length < 4) {et_value = "0" + et_value;} + var st_hour=st_value.substring(0,2); + var st_min=st_value.substring(2,4); + var et_hour=et_value.substring(0,2); + var et_min=et_value.substring(2,4); + if (st_hour > 23) {st_hour = 23;} + if (et_hour > 23) {et_hour = 23;} + if (st_min > 59) {st_min = 59;} + if (et_min > 59) {et_min = 59;} + start_time.value = st_hour + "" + st_min; + end_time.value = et_hour + "" + et_min; + var start_time_hour=start_time.value.substring(0,2); var start_time_min=start_time.value.substring(2,4); var end_time_hour=end_time.value.substring(0,2); @@ -7387,8 +7461,7 @@ if ($ADD=="2A") $stmt="UPDATE system_settings SET auto_user_add_value='$user';"; $rslt=mysql_query($stmt, $link); } - - $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists) SELECT \"$user\",\"$pass\",\"$full_name\",user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists from vicidial_users where user=\"$source_user_id\";"; + $stmt="INSERT INTO vicidial_users (user,pass,full_name,user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override) SELECT \"$user\",\"$pass\",\"$full_name\",user_level,user_group,phone_login,phone_pass,delete_users,delete_user_groups,delete_lists,delete_campaigns,delete_ingroups,delete_remote_agents,load_leads,campaign_detail,ast_admin_access,ast_delete_phones,delete_scripts,modify_leads,hotkeys_active,change_agent_campaign,agent_choose_ingroups,closer_campaigns,scheduled_callbacks,agentonly_callbacks,agentcall_manual,vicidial_recording,vicidial_transfers,delete_filters,alter_agent_interface_options,closer_default_blended,delete_call_times,modify_call_times,modify_users,modify_campaigns,modify_lists,modify_scripts,modify_filters,modify_ingroups,modify_usergroups,modify_remoteagents,modify_servers,view_reports,vicidial_recording_override,alter_custdata_override,qc_enabled,qc_user_level,qc_pass,qc_finish,qc_commit,add_timeclock_log,modify_timeclock_log,delete_timeclock_log,alter_custphone_override,vdc_agent_api_access,modify_inbound_dids,delete_inbound_dids,active,alert_enabled,download_lists,agent_shift_enforcement_override,manager_shift_enforcement_override from vicidial_users where user=\"$source_user_id\";"; $rslt=mysql_query($stmt, $link); $stmtA="INSERT INTO vicidial_inbound_group_agents (user,group_id,group_rank,group_weight,calls_today) SELECT \"$user\",group_id,group_rank,group_weight,\"0\" from vicidial_inbound_group_agents where user=\"$source_user_id\";"; @@ -9097,7 +9170,7 @@ if ($ADD=="4A") } echo "
USER MODIFIED - ADMIN: $user\n"; - $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times',modify_users='$modify_users',modify_campaigns='$modify_campaigns',modify_lists='$modify_lists',modify_scripts='$modify_scripts',modify_filters='$modify_filters',modify_ingroups='$modify_ingroups',modify_usergroups='$modify_usergroups',modify_remoteagents='$modify_remoteagents',modify_servers='$modify_servers',view_reports='$view_reports',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',add_timeclock_log='$add_timeclock_log',modify_timeclock_log='$modify_timeclock_log',delete_timeclock_log='$delete_timeclock_log',alter_custphone_override='$alter_custphone_override',vdc_agent_api_access='$vdc_agent_api_access',modify_inbound_dids='$modify_inbound_dids',delete_inbound_dids='$delete_inbound_dids',active='$active',download_lists='$download_lists' where user='$user';"; + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',delete_users='$delete_users',delete_user_groups='$delete_user_groups',delete_lists='$delete_lists',delete_campaigns='$delete_campaigns',delete_ingroups='$delete_ingroups',delete_remote_agents='$delete_remote_agents',load_leads='$load_leads',campaign_detail='$campaign_detail',ast_admin_access='$ast_admin_access',ast_delete_phones='$ast_delete_phones',delete_scripts='$delete_scripts',modify_leads='$modify_leads',hotkeys_active='$hotkeys_active',change_agent_campaign='$change_agent_campaign',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',delete_filters='$delete_filters',alter_agent_interface_options='$alter_agent_interface_options',closer_default_blended='$closer_default_blended',delete_call_times='$delete_call_times',modify_call_times='$modify_call_times',modify_users='$modify_users',modify_campaigns='$modify_campaigns',modify_lists='$modify_lists',modify_scripts='$modify_scripts',modify_filters='$modify_filters',modify_ingroups='$modify_ingroups',modify_usergroups='$modify_usergroups',modify_remoteagents='$modify_remoteagents',modify_servers='$modify_servers',view_reports='$view_reports',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',add_timeclock_log='$add_timeclock_log',modify_timeclock_log='$modify_timeclock_log',delete_timeclock_log='$delete_timeclock_log',alter_custphone_override='$alter_custphone_override',vdc_agent_api_access='$vdc_agent_api_access',modify_inbound_dids='$modify_inbound_dids',delete_inbound_dids='$delete_inbound_dids',active='$active',download_lists='$download_lists',agent_shift_enforcement_override='$agent_shift_enforcement_override',manager_shift_enforcement_override='$manager_shift_enforcement_override' where user='$user';"; $rslt=mysql_query($stmt, $link); @@ -9330,7 +9403,7 @@ if ($ADD=="4B") } echo "
USER MODIFIED - ADMIN: $user\n"; - $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',alter_custphone_override='$alter_custphone_override',active='$active' where user='$user';"; + $stmt="UPDATE vicidial_users set pass='$pass',full_name='$full_name',user_level='$user_level',user_group='$user_group',phone_login='$phone_login',phone_pass='$phone_pass',hotkeys_active='$hotkeys_active',agent_choose_ingroups='$agent_choose_ingroups',closer_campaigns='$groups_value',scheduled_callbacks='$scheduled_callbacks',agentonly_callbacks='$agentonly_callbacks',agentcall_manual='$agentcall_manual',vicidial_recording='$vicidial_recording',vicidial_transfers='$vicidial_transfers',closer_default_blended='$closer_default_blended',vicidial_recording_override='$vicidial_recording_override',alter_custdata_override='$alter_custdata_override',qc_enabled='$qc_enabled',qc_user_level='$qc_user_level',qc_pass='$qc_pass',qc_finish='$qc_finish',qc_commit='$qc_commit',alter_custphone_override='$alter_custphone_override',active='$active',agent_shift_enforcement_override='$agent_shift_enforcement_override' where user='$user';"; $rslt=mysql_query($stmt, $link); @@ -10846,7 +10919,7 @@ if ($ADD==411111) $GROUP_shifts .= "$group_shifts[$p] "; $p++; } - $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name',allowed_campaigns='$campaigns_value',qc_allowed_campaigns='$qc_campaigns_value',qc_allowed_inbound_groups='$qc_groups_value',group_shifts='$GROUP_shifts',forced_timeclock_login='$forced_timeclock_login' where user_group='$OLDuser_group';"; + $stmt="UPDATE vicidial_user_groups set user_group='$user_group', group_name='$group_name',allowed_campaigns='$campaigns_value',qc_allowed_campaigns='$qc_campaigns_value',qc_allowed_inbound_groups='$qc_groups_value',group_shifts='$GROUP_shifts',forced_timeclock_login='$forced_timeclock_login',shift_enforcement='$shift_enforcement' where user_group='$OLDuser_group';"; $rslt=mysql_query($stmt, $link); echo "
USER GROUP MODIFIED\n"; @@ -11352,7 +11425,7 @@ if ($ADD==411111111111) { echo "
SERVER MODIFIED: $server_ip\n"; - $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output', vicidial_balance_active='$vicidial_balance_active',balance_trunks_offlimits='$balance_trunks_offlimits',recording_web_link='$recording_web_link',alt_server_ip='$alt_server_ip',active_asterisk_server='$active_asterisk_server',generate_vicidial_conf='$generate_vicidial_conf',rebuild_conf_files='$rebuild_conf_files' where server_id='$old_server_id';"; + $stmt="UPDATE servers set server_id='$server_id',server_description='$server_description',server_ip='$server_ip',active='$active',asterisk_version='$asterisk_version', max_vicidial_trunks='$max_vicidial_trunks', telnet_host='$telnet_host', telnet_port='$telnet_port', ASTmgrUSERNAME='$ASTmgrUSERNAME', ASTmgrSECRET='$ASTmgrSECRET', ASTmgrUSERNAMEupdate='$ASTmgrUSERNAMEupdate', ASTmgrUSERNAMElisten='$ASTmgrUSERNAMElisten', ASTmgrUSERNAMEsend='$ASTmgrUSERNAMEsend', local_gmt='$local_gmt', voicemail_dump_exten='$voicemail_dump_exten', answer_transfer_agent='$answer_transfer_agent', ext_context='$ext_context', sys_perf_log='$sys_perf_log', vd_server_logs='$vd_server_logs', agi_output='$agi_output', vicidial_balance_active='$vicidial_balance_active',balance_trunks_offlimits='$balance_trunks_offlimits',recording_web_link='$recording_web_link',alt_server_ip='$alt_server_ip',active_asterisk_server='$active_asterisk_server',generate_vicidial_conf='$generate_vicidial_conf',rebuild_conf_files='$rebuild_conf_files',outbound_calls_per_second='$outbound_calls_per_second' where server_id='$old_server_id';"; $rslt=mysql_query($stmt, $link); $stmt="UPDATE servers SET rebuild_conf_files='Y' where generate_vicidial_conf='Y' and active_asterisk_server='Y';"; @@ -11604,7 +11677,7 @@ if ($ADD==411111111111111) echo "
VICIDIAL SYSTEM SETTINGS MODIFIED\n"; - $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active';"; + $stmt="UPDATE system_settings set use_non_latin='$use_non_latin',webroot_writable='$webroot_writable',enable_queuemetrics_logging='$enable_queuemetrics_logging',queuemetrics_server_ip='$queuemetrics_server_ip',queuemetrics_dbname='$queuemetrics_dbname',queuemetrics_login='$queuemetrics_login',queuemetrics_pass='$queuemetrics_pass',queuemetrics_url='$queuemetrics_url',queuemetrics_log_id='$queuemetrics_log_id',queuemetrics_eq_prepend='$queuemetrics_eq_prepend',vicidial_agent_disable='$vicidial_agent_disable',allow_sipsak_messages='$allow_sipsak_messages',admin_home_url='$admin_home_url',enable_agc_xfer_log='$enable_agc_xfer_log',timeclock_end_of_day='$timeclock_end_of_day',vdc_header_date_format='$vdc_header_date_format',vdc_customer_date_format='$vdc_customer_date_format',vdc_header_phone_format='$vdc_header_phone_format',vdc_agent_api_active='$vdc_agent_api_active',enable_vtiger_integration='$enable_vtiger_integration',vtiger_server_ip='$vtiger_server_ip',vtiger_dbname='$vtiger_dbname',vtiger_login='$vtiger_login',vtiger_pass='$vtiger_pass',vtiger_url='$vtiger_url',qc_features_active='$qc_features_active',outbound_autodial_active='$outbound_autodial_active',outbound_calls_per_second='$outbound_calls_per_second';"; $rslt=mysql_query($stmt, $link); ### LOG CHANGES TO LOG FILE ### @@ -13488,6 +13561,8 @@ if ($ADD==3) $active = $row[58]; $alert_enabled = $row[59]; $download_lists = $row[60]; + $agent_shift_enforcement_override = $row[61]; + $manager_shift_enforcement_override = $row[62]; if ( ($user_level >= $LOGuser_level) and ($LOGuser_level < 9) ) { @@ -13555,6 +13630,9 @@ if ($ADD==3) echo "
VICIDIAL Recording Override: $NWB#vicidial_users-vicidial_recording_override$NWE
Agent Alter Customer Data Override: $NWB#vicidial_users-alter_custdata_override$NWE
Agent Alter Customer Phone Override: $NWB#vicidial_users-alter_custphone_override$NWE
Agent Shift Enforcement Override: $NWB#vicidial_users-agent_shift_enforcement_override$NWE
Alert Enabled: $alert_enabled $NWB#vicidial_users-alert_enabled$NWE
Campaign Ranks: $NWB#vicidial_users-campaign_ranks$NWE
\n"; @@ -13628,6 +13706,9 @@ if ($ADD==3) echo "
Add Timeclock Log Record: $NWB#vicidial_users-add_timeclock_log$NWE
Modify Timeclock Log Record: $NWB#vicidial_users-modify_timeclock_log$NWE
Delete Timeclock Log Record: $NWB#vicidial_users-delete_timeclock_log$NWE
Manager Shift Enforcement Override: $NWB#vicidial_users-manager_shift_enforcement_override$NWE
\n"; @@ -16933,6 +17014,8 @@ if ($ADD==311111) $group_name = $row[1]; $GROUP_shifts = $row[5]; $forced_timeclock_login = $row[6]; + $shift_enforcement = $row[7]; + echo ""; echo "
MODIFY A USERS GROUP ENTRY
\n"; @@ -16944,6 +17027,8 @@ if ($ADD==311111) echo "Force Timeclock Login: $NWB#vicidial_user_groups-forced_timeclock_login$NWE\n"; + echo "Shift Enforcement: $NWB#vicidial_user_groups-shift_enforcement$NWE\n"; + echo "Allowed Campaigns:
$NWB#vicidial_user_groups-allowed_campaigns$NWE\n"; echo "$campaigns_list
 "; echo "\n"; @@ -17830,44 +17915,84 @@ if ($ADD==311111111111) echo "
\n"; echo ""; - $stmt="SELECT * from servers where server_id='$server_id' or server_ip='$server_ip';"; + $stmt="SELECT server_id,server_description,server_ip,active,asterisk_version,max_vicidial_trunks,telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,local_gmt,voicemail_dump_exten,answer_transfer_agent,ext_context,sys_perf_log,vd_server_logs,agi_output,vicidial_balance_active,balance_trunks_offlimits,recording_web_link,alt_server_ip,active_asterisk_server,generate_vicidial_conf,rebuild_conf_files,outbound_calls_per_second,sysload,channels_total,cpu_idle_percent,disk_usage from servers where server_id='$server_id' or server_ip='$server_ip';"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); - $server_id = $row[0]; - $server_ip = $row[2]; + $server_id = $row[0]; + $server_description = $row[1]; + $server_ip = $row[2]; + $active = $row[3]; + $asterisk_version = $row[4]; + $max_vicidial_trunks = $row[5]; + $telnet_host = $row[6]; + $telnet_port = $row[7]; + $ASTmgrUSERNAME = $row[8]; + $ASTmgrSECRET = $row[9]; + $ASTmgrUSERNAMEupdate = $row[10]; + $ASTmgrUSERNAMElisten = $row[11]; + $ASTmgrUSERNAMEsend = $row[12]; + $local_gmt = $row[13]; + $voicemail_dump_exten = $row[14]; + $answer_transfer_agent = $row[15]; + $ext_context = $row[16]; + $sys_perf_log = $row[17]; + $vd_server_logs = $row[18]; + $agi_output = $row[19]; + $vicidial_balance_active = $row[20]; + $balance_trunks_offlimits = $row[21]; + $recording_web_link = $row[22]; + $alt_server_ip = $row[23]; + $active_asterisk_server = $row[24]; + $generate_vicidial_conf = $row[25]; + $rebuild_conf_files = $row[26]; + $outbound_calls_per_second = $row[27]; + $sysload = $row[28]; + $channels_total = $row[29]; + $cpu_idle_percent = $row[30]; + $disk_usage = $row[31]; + + $cpu = (100 - $cpu_idle_percent); + $disk_usage = preg_replace("/ /"," - ",$disk_usage); + $disk_usage = preg_replace("/\|/","%     ",$disk_usage); echo "
MODIFY A SERVER RECORD: $row[0]\n"; echo "\n"; echo "\n"; - echo "\n"; + echo "\n"; echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; @@ -18366,7 +18491,7 @@ if ($ADD==311111111111111) echo "
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
Max VICIDIAL Trunks: $NWB#servers-max_vicidial_trunks$NWE
VICIDIAL Balance Dialing: $NWB#servers-vicidial_balance_active$NWE
VICIDIAL Balance Offlimits: $NWB#servers-balance_trunks_offlimits$NWE
Telnet Host: $NWB#servers-telnet_host$NWE
Telnet Port: $NWB#servers-telnet_port$NWE
Manager User: $NWB#servers-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#servers-ASTmgrSECRET$NWE
Manager Update User: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Listen User: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Send User: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL AD extension: $NWB#servers-answer_transfer_agent$NWE
Default Context: $NWB#servers-ext_context$NWE
System Performance: $NWB#servers-sys_perf_log$NWE
Server Logs: $NWB#servers-vd_server_logs$NWE
AGI Output: $NWB#servers-agi_output$NWE
Recording Web Link: $NWB#servers-recording_web_link$NWE
Alternate Recording Server IP: $NWB#servers-alt_server_ip$NWE
Active Asterisk Server: $NWB#servers-active_asterisk_server$NWE
Generate conf files: $NWB#servers-generate_vicidial_conf$NWE
Rebuild conf files: $NWB#servers-rebuild_conf_files$NWE
Server ID: $NWB#servers-server_id$NWE
Server Description: $NWB#servers-server_description$NWE
Server IP Address: $NWB#servers-server_ip$NWE
Active: $NWB#servers-active$NWE
System Load: $sysload - $cpu%   $NWB#servers-sysload$NWE
Live Channels: $channels_total   $NWB#servers-channels_total$NWE
Disk Usage: $disk_usage   $NWB#servers-disk_usage$NWE
Asterisk Version: $NWB#servers-asterisk_version$NWE
Max VICIDIAL Trunks: $NWB#servers-max_vicidial_trunks$NWE
Max Calls per Second: $NWB#servers-outbound_calls_per_second$NWE
VICIDIAL Balance Dialing: $NWB#servers-vicidial_balance_active$NWE
VICIDIAL Balance Offlimits: $NWB#servers-balance_trunks_offlimits$NWE
Telnet Host: $NWB#servers-telnet_host$NWE
Telnet Port: $NWB#servers-telnet_port$NWE
Manager User: $NWB#servers-ASTmgrUSERNAME$NWE
Manager Secret: $NWB#servers-ASTmgrSECRET$NWE
Manager Update User: $NWB#servers-ASTmgrUSERNAMEupdate$NWE
Manager Listen User: $NWB#servers-ASTmgrUSERNAMElisten$NWE
Manager Send User: $NWB#servers-ASTmgrUSERNAMEsend$NWE
Local GMT: (Do NOT Adjust for DST)$NWB#servers-local_gmt$NWE
VMail Dump Exten: $NWB#servers-voicemail_dump_exten$NWE
VICIDIAL AD extension: $NWB#servers-answer_transfer_agent$NWE
Default Context: $NWB#servers-ext_context$NWE
System Performance: $NWB#servers-sys_perf_log$NWE
Server Logs: $NWB#servers-vd_server_logs$NWE
AGI Output: $NWB#servers-agi_output$NWE
Recording Web Link: $NWB#servers-recording_web_link$NWE
Alternate Recording Server IP: $NWB#servers-alt_server_ip$NWE
Active Asterisk Server: $NWB#servers-active_asterisk_server$NWE
Generate conf files: $NWB#servers-generate_vicidial_conf$NWE
Rebuild conf files: $NWB#servers-rebuild_conf_files$NWE
\n"; echo "\n"; + echo "\n"; + echo "\n"; echo "\n"; echo "\n"; @@ -19998,95 +20126,117 @@ if ($ADD==10000000000000) # ADD=999999 display reports section ###################### if ($ADD==999999) -{ - if ($LOGview_reports==1) { - echo "
\n"; echo ""; - $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active from system_settings;"; + $stmt="SELECT version,install_date,use_non_latin,webroot_writable,enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_url,queuemetrics_log_id,queuemetrics_eq_prepend,vicidial_agent_disable,allow_sipsak_messages,admin_home_url,enable_agc_xfer_log,db_schema_version,auto_user_add_value,timeclock_end_of_day,timeclock_last_reset_date,vdc_header_date_format,vdc_customer_date_format,vdc_header_phone_format,vdc_agent_api_active,qc_last_pull_time,enable_vtiger_integration,vtiger_server_ip,vtiger_dbname,vtiger_login,vtiger_pass,vtiger_url,qc_features_active,outbound_autodial_active,outbound_calls_per_second from system_settings;"; $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); $version = $row[0]; @@ -18402,6 +18527,7 @@ if ($ADD==311111111111111) $vtiger_url = $row[30]; $qc_features_active = $row[31]; $outbound_autodial_active = $row[32]; + $outbound_calls_per_second = $row[33]; echo "
MODIFY VICIDIAL SYSTEM SETTINGS\n"; echo "\n"; @@ -18461,6 +18587,8 @@ if ($ADD==311111111111111) echo "
QC Features Active: $NWB#settings-qc_features_active$NWE
Outbound Auto-Dial Active: $NWB#settings-outbound_autodial_active$NWE
Max FILL Calls per Second: $NWB#settings-outbound_calls_per_second$NWE
Enable QueueMetrics Logging: $NWB#settings-enable_queuemetrics_logging$NWE
QueueMetrics Server IP: $NWB#settings-queuemetrics_server_ip$NWE
QueueMetrics DB Name: $NWB#settings-queuemetrics_dbname$NWE
\n"; - echo ""; - - $stmt="select * from servers;"; - $rslt=mysql_query($stmt, $link); - if ($DB) {echo "$stmt\n";} - $servers_to_print = mysql_num_rows($rslt); - $i=0; - while ($i < $servers_to_print) + if ($LOGview_reports==1) { + echo "
\n"; + echo ""; + + $stmt="select server_id,server_description,server_ip,active,sysload,channels_total,cpu_idle_percent,disk_usage from servers;"; + $rslt=mysql_query($stmt, $link); + if ($DB) {echo "$stmt\n";} + $servers_to_print = mysql_num_rows($rslt); + $i=0; + while ($i < $servers_to_print) + { + $row=mysql_fetch_row($rslt); + $server_id[$i] = $row[0]; + $server_description[$i] = $row[1]; + $server_ip[$i] = $row[2]; + $active[$i] = $row[3]; + $sysload[$i] = $row[4]; + $channels_total[$i] = $row[5]; + $cpu_idle_percent[$i] = $row[6]; + $disk_usage[$i] = $row[7]; + $i++; + } + + $stmt="SELECT queuemetrics_url,vtiger_url from system_settings;"; + $rslt=mysql_query($stmt, $link); $row=mysql_fetch_row($rslt); - $server_id[$i] = $row[0]; - $server_description[$i] = $row[1]; - $server_ip[$i] = $row[2]; - $active[$i] = $row[3]; - $i++; - } + $queuemetrics_url_LU = $row[0]; + $vtiger_url_LU = $row[1]; - $stmt="SELECT queuemetrics_url,vtiger_url from system_settings;"; - $rslt=mysql_query($stmt, $link); - $row=mysql_fetch_row($rslt); - $queuemetrics_url_LU = $row[0]; - $vtiger_url_LU = $row[1]; + ?> + + + + + VICIDIAL: Server Stats and Reports + VICIDIAL: Server Stats and Reports

+
\n"; + } else - { - echo "You do not have permission to view this page\n"; - exit; + { + echo "You do not have permission to view this page\n"; + exit; + } } -}