Added compatability in the Vicidial code for Asterisk 11

Added database and logfile logging of DTMF events. Works with Asterisk versions 1.8 and higher

git-svn-id: svn://192.168.202.10@2347 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-07-13 03:05:49 +00:00
parent e41b19c9a6
commit 6a3d4267df
13 changed files with 181 additions and 29 deletions
+6
View File
@@ -97,6 +97,12 @@ OTHER CHANGES:
16. Added the ability to define multiple Dispo Call URLs as well as define
specific statuses that they will be triggered for.
17. Added compatability in the Vicidial code for Asterisk 11.
18. Added database and logfile logging of DTMF events. Works with Asterisk
versions 1.8 and higher. If upgrading, you will need to add "dtmf" to
the listencron user in manager.conf and reload asterisk.
+24
View File
@@ -39,6 +39,7 @@
# 140107-1508 - Added rolling of vicidial_api_log entries
# 140305-0955 - Changed to use --days (--months is approximation[bug fix]), changed default from 2 months to 2 years
# 150107-2308 - Added vicidial_api_log to daily process
# 150712-2208 - Added vicidial_dtmf_log
#
$CALC_TEST=0;
@@ -974,6 +975,29 @@ if (!$T)
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
##### vicidial_dtmf_log
$stmtA = "SELECT count(*) from vicidial_dtmf_log;";
$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;
$vicidial_dtmf_log_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_dtmf_log table... ($vicidial_dtmf_log_count)\n";}
$stmtA = "DELETE FROM vicidial_dtmf_log WHERE dtmf_time < '$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows = $sthA->rows;
if (!$Q) {print "$sthArows rows deleted from vicidial_dtmf_log table \n";}
$stmtA = "optimize table vicidial_dtmf_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
##### vicidial_agent_log
$stmtA = "SELECT count(*) from vicidial_agent_log;";
+8 -2
View File
@@ -1,12 +1,12 @@
#!/usr/bin/perl
#
# ADMIN_audio_store_sync.pl version 2.10
# ADMIN_audio_store_sync.pl version 2.12
#
# DESCRIPTION:
# syncronizes audio between audio store and this server
#
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGELOG
# 90513-0458 - First Build
@@ -18,6 +18,7 @@
# 121019-0729 - Added audio_store_purge feature
# 141124-2309 - Fixed Fhour variable bug
# 141125-1555 - Added audio_store_details audio file info gathering and DB population
# 150712-2210 - Added touch of conf files to Asterisk will notice changes
#
# constants
@@ -737,6 +738,11 @@ if ( ($force_moh_rebuild > 0) || ($new_file_moh_rebuild > 0) || ($rebuild_music_
### reloading moh in Asterisk
if ($DBX)
{print "reloading moh in asterisk\n";}
# Asterisk 11 will only reload a config file once after it's a time changes, so we need to touch conf files
`touch /etc/asterisk/musiconhold.conf`;
`touch /etc/asterisk/musiconhold-vicidial.conf`;
`screen -XS asterisk eval 'stuff "moh reload\015"'`;
}
+5 -4
View File
@@ -1,10 +1,10 @@
#!/usr/bin/perl
#
# AST_conf_update.pl version 2.6
# AST_conf_update.pl version 2.12
#
# This script checks if there are channels in reserved conferences
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# 50810-1532 - Added database server variable definitions lookup
# 50823-1456 - Added commandline arguments for debug at runtime
@@ -17,6 +17,7 @@
# 100811-2054 - Added --no-vc-3way-check flag to use when AST_conf_update_3way.pl script is used
# 100928-1506 - Changed from hard-coded 60 minute limit to servers.vicidial_recording_limit
# 130108-1712 - Changes for Asterisk 1.8 compatibility
# 150610-1200 - Added support for AMI version 1.3
#
# constants
@@ -256,7 +257,7 @@ if ($no_vc_3way_check < 1)
else {$telnet_login = $ASTmgrUSERNAME;}
$t->open("$telnet_host");
$t->waitfor('/[01]\n$/'); # print login
$t->waitfor('/[0123]\n$/'); # print login
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
@@ -385,7 +386,7 @@ if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
else {$telnet_login = $ASTmgrUSERNAME;}
$t->open("$telnet_host");
$t->waitfor('/[01]\n$/'); # print login
$t->waitfor('/[0123]\n$/'); # print login
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
+21 -2
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# AST_flush_DBqueue.pl version 2.4
# AST_flush_DBqueue.pl version 2.12
#
# DESCRIPTION:
# - clears out mysql records for this server for the ACQS vicidial_manager table
@@ -9,7 +9,7 @@
# !!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!
# THIS SCRIPT SHOULD ONLY BE RUN ON ONE SERVER ON YOUR CLUSTER
#
# Copyright (C) 2012 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 60717-1214 - changed to DBI by Marin Blu
@@ -19,6 +19,7 @@
# 91206-2149 - Added vicidial_campaigns and vicidial_lists optimization
# 120404-1315 - Changed to run only on DB server<you should remove from other servers' crontabs>
# 120411-1637 - Added --seconds option
# 150710-0907 - Added flush of vicidial_dtmf table
#
### begin parsing run-time options ###
@@ -197,6 +198,10 @@ if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) { $affected_rows = $dbhA->do($stmtA);}
if (!$Q) {print " - vicidial_manager flush\n";}
$stmtA = "DELETE from vicidial_dtmf where dtmf_time < '$flush_time';";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T) { $affected_rows = $dbhA->do($stmtA);}
if (!$Q) {print " - vicidial_dtmf flush\n";}
$stmtA = "OPTIMIZE table vicidial_manager;";
if($DB){print STDERR "\n|$stmtA|\n";}
@@ -212,6 +217,20 @@ if (!$T)
if (!$Q) {print " - OPTIMIZE vicidial_manager \n";}
$stmtA = "OPTIMIZE table vicidial_dtmf;";
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();
}
if (!$Q) {print " - OPTIMIZE vicidial_dtmf \n";}
$stmtA = "OPTIMIZE table vicidial_live_agents;";
if($DB){print STDERR "\n|$stmtA|\n";}
if (!$T)
+72 -8
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# AST_manager_listen.pl version 2.10
# AST_manager_listen.pl version 2.12
#
# Part of the Asterisk Central Queue System (ACQS)
#
@@ -17,7 +17,7 @@
# the ADMIN_keepalive_ALL.pl script, which makes sure it is always running in a
# screen, provided that the astguiclient.conf keepalive setting "2" is set.
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 50322-1300 - changed callerid parsing to remove quotes and number
@@ -44,6 +44,8 @@
# 141113-1605 - Added concurrency check
# 141124-2309 - Fixed Fhour variable bug
# 141219-1137 - Change to keepalive processes to not run at busy times and not drop buffer
# 150610-1200 - Added support for AMI version 1.3
# 150709-1506 - Added DTMF logging for Asterisk 1.8 and higher
#
# constants
@@ -227,13 +229,13 @@ while($one_day_interval > 0)
if (length($ASTmgrUSERNAMElisten) > 3) {$telnet_login = $ASTmgrUSERNAMElisten;}
else {$telnet_login = $ASTmgrUSERNAME;}
$tn->open("$telnet_host");
$tn->waitfor('/[01]\n$/'); # print login
$tn->waitfor('/[0123]\n$/'); # print login
$tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted
$tn->buffer_empty;
$tn->buffer_empty;
$event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|ONE DAY INTERVAL:$one_day_interval|";
$event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|ONE DAY INTERVAL:$one_day_interval|";
&event_logger;
$endless_loop=864000; # 1 day at .10 seconds per loop
@@ -784,7 +786,7 @@ while($one_day_interval > 0)
$endless_loop--;
$keepalive_count_loop++;
if($DB){print STDERR " loop counter: |$endless_loop|$keepalive_count_loop| |$vddl_update|$vdcl_update|\r";}
if($DB){print STDERR " loop counter: |$endless_loop|$keepalive_count_loop| |$vddl_update|$vdcl_update|\r";}
### putting a blank file called "sendmgr.kill" in a directory will automatically safely kill this program
if ( (-e "$PATHhome/listenmgr.kill") or ($sendonlyone) )
@@ -992,7 +994,7 @@ while($one_day_interval > 0)
}
##### parse through all other important events #####
if ( ($input_lines[$ILcount] =~ /Event: Newstate|Event: Hangup|Event: NewCallerid|Event: Shutdown|Event: CPD-Result|Event: SIP-Hangup-Cause/) && ($input_lines[$ILcount] !~ /ZOMBIE/) )
if ( ($input_lines[$ILcount] =~ /Event: Newstate|Event: Hangup|Event: NewCallerid|Event: Shutdown|Event: CPD-Result|Event: SIP-Hangup-Cause|Event: DTMF/) && ($input_lines[$ILcount] !~ /ZOMBIE/) )
{
$input_lines[$ILcount] =~ s/^\n|^\n\n//gi;
@command_line=split(/\n/, $input_lines[$ILcount]);
@@ -1111,6 +1113,57 @@ while($one_day_interval > 0)
}
}
### Event: DTMF
if ($input_lines[$ILcount] =~ /Event: DTMF/)
{
if ( ($command_line[2] =~ /^Channel: /i) && ($command_line[3] =~ /^Uniqueid: /i) )
{
# get the event info
$channel = $command_line[2];
$channel =~ s/Channel: |\s*$//gi;
$uniqueid = $command_line[3];
$uniqueid =~ s/Uniqueid: |\s*$//gi;
$digit = $command_line[4];
$digit =~ s/Digit: |\s*$//gi;
$direction = $command_line[5];
$direction =~ s/Direction: |\s*$//gi;
$begin = $command_line[6];
$begin =~ s/Begin: |\s*$//gi;
$end = $command_line[7];
$end =~ s/End: |\s*$//gi;
# set the state
$state = '';
if ($begin eq 'Yes') {$state = 'Begin';}
else
{
if ($end eq 'Yes') {$state = 'End';}
}
# log it to the DB and file
$stmtA = "INSERT INTO vicidial_dtmf_log SET dtmf_time=NOW(),channel='$channel',server_ip='$server_ip',uniqueid='$uniqueid',digit='$digit',direction='$direction',state='$state'";
print STDERR "|$stmtA|\n";
my $affected_rows = $dbhA->do($stmtA);
($s_hires, $usec) = gettimeofday(); # get seconds and microseconds since the epoch
$usec = sprintf("%06s", $usec);
$HRmsec = substr($usec, -6);
($HRsec,$HRmin,$HRhour,$HRmday,$HRmon,$HRyear,$HRwday,$HRyday,$HRisdst) = localtime($s_hires);
$HRyear = ($HRyear + 1900);
$HRmon++;
if ($HRmon < 10) {$HRmon = "0$HRmon";}
if ($HRmday < 10) {$HRmday = "0$HRmday";}
if ($HRhour < 10) {$HRFhour = "0$HRhour";}
if ($HRmin < 10) {$HRmin = "0$HRmin";}
if ($HRsec < 10) {$HRsec = "0$HRsec";}
$HRnow_date = "$HRyear-$HRmon-$HRmday $HRhour:$HRmin:$HRsec.$HRmsec";
if($DB){print "|$affected_rows vicidial_dtmf inserted|$HRnow_date|$s_hires|$usec|\n";}
$dtmf_string = "$HRnow_date|$s_hires|$usec|$channel|$uniqueid|$digit|$direction|$state";
&dtmf_logger;
}
}
### Event: CPD-Result
if ($input_lines[$ILcount] =~ /Event: CPD-Result/)
{
@@ -1261,7 +1314,7 @@ while($one_day_interval > 0)
$endless_loop--;
$keepalive_count_loop++;
if($DB){print STDERR " loop counter: |$endless_loop|$keepalive_count_loop| |$vddl_update|$vdcl_update|\r";}
if($DB){print STDERR " loop counter: |$endless_loop|$keepalive_count_loop| |$vddl_update|$vdcl_update|\r";}
### putting a blank file called "sendmgr.kill" in a directory will automatically safely kill this program
if ( (-e "$PATHhome/listenmgr.kill") or ($sendonlyone) )
@@ -1418,6 +1471,17 @@ sub manager_output_logger
}
}
sub dtmf_logger
{
if ($SYSLOG)
{
open(Dout, ">>$PATHlogs/dtmf.$action_log_date")
|| die "Can't open $PATHlogs/dttmf.$action_log_date: $!\n";
print Dout "|$dtmf_string|\n";
close(Dout);
}
}
# subroutine to parse the asterisk version
# and return a hash with the various part
sub parse_asterisk_version
+5 -4
View File
@@ -1,16 +1,17 @@
#!/usr/bin/perl
#
# AST_phone_update.pl version 2.8
# AST_phone_update.pl version 2.12
#
# DESCRIPTION:
# checks the registered IP address of the phone and updates the phones table
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# 70521-1529 - first build
# 100625-1220 - Added waitfors after logout to fix broken pipe errors in asterisk <MikeC>
# 130625-0947 - Added --agent-lookup option for agent phone_ip population
# 131210-1305 - Added Asterisk 1.8 compatibility
# 150610-1200 - Added support for AMI version 1.3
#
# constants
@@ -222,7 +223,7 @@ if ( ($sip_count > 0) || ($agent_lookup < 1) )
else {$telnet_login = $ASTmgrUSERNAME;}
$t->open("$telnet_host");
$t->waitfor('/[01]\n$/'); # print login
$t->waitfor('/[0123]\n$/'); # print login
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
@@ -350,7 +351,7 @@ if ( ($iax_count > 0) || ($agent_lookup < 1) )
else {$telnet_login = $ASTmgrUSERNAME;}
$t->open("$telnet_host");
$t->waitfor('/[01]\n$/'); # print login
$t->waitfor('/[0123]\n$/'); # print login
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
+4 -3
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# AST_send_action_child.pl version 2.6
# AST_send_action_child.pl version 2.12
#
# Part of the Asterisk Central Queue System (ACQS)
#
@@ -14,7 +14,7 @@
# to be executed. connect to the manager interface, send the action and logoff
# then exit.
#
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# CHANGES
# 50810-1547 - Added database server variable definitions lookup
@@ -31,6 +31,7 @@
# 100625-1141 - Added waitfors after orginate and logout to fix broken pipe errors in asterisk <MikeC>
# 100625-1206 - Use strict is a performance hit and should only be uncommented for debugging <MikeC>
# 130108-1714 - Changes for Asterisk 1.8 compatibility
# 150610-1200 - Added support for AMI version 1.3
#
$|++;
@@ -171,7 +172,7 @@ if ($action) {
$telnet_login = $ASTmgrUSERNAME;
}
$tn->open($telnet_host);
$tn->waitfor('/[01]\n$/'); # print login
$tn->waitfor('/[0123]\n$/'); # print login
$tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted
+2 -1
View File
@@ -64,6 +64,7 @@
# 141113-1601 - Added concurrency check
# 141124-2309 - Fixed Fhour variable bug
# 150308-0911 - Added filter for agent sessions in new meetme-enter contexts
# 150610-1200 - Added support for AMI version 1.3
#
$build = '150308-0911';
@@ -455,7 +456,7 @@ while($one_day_interval > 0)
if (length($ASTmgrUSERNAMEupdate) > 3) {$telnet_login = $ASTmgrUSERNAMEupdate;}
else {$telnet_login = $ASTmgrUSERNAME;}
$t->open("$telnet_host");
$t->waitfor('/[01]\n$/'); # print login
$t->waitfor('/[0123]\n$/'); # print login
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
+4 -3
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# AST_vm_update.pl version 2.10
# AST_vm_update.pl version 2.12
#
# DESCRIPTION:
# uses the Asterisk Manager interface to update the count of voicemail messages
@@ -14,7 +14,7 @@
#
# NOTE: THIS SHOULD ONLY BE RUN ON THE DESIGNATED VOICEMAIL SERVER IN A CLUSTER!
#
# Copyright (C) 2014 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
# Copyright (C) 2015 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
#
# 50823-1422 - Added database server variable definitions lookup
# 50823-1452 - Added commandline arguments for debug at runtime
@@ -24,6 +24,7 @@
# 100625-1220 - Added waitfors after logout to fix broken pipe errors in asterisk <MikeC>
# 130108-1713 - Changes for Asterisk 1.8 compatibility
# 141124-1019 - Changed to only allow running on designated voicemail server, run for all mailboxes
# 150610-1200 - Added support for AMI version 1.3
#
# constants
@@ -194,7 +195,7 @@ if (length($ASTmgrUSERNAMEsend) > 3) {$telnet_login = $ASTmgrUSERNAMEsend;}
else {$telnet_login = $ASTmgrUSERNAME;}
$t->open("$telnet_host");
$t->waitfor('/[01]\n$/'); # print login
$t->waitfor('/[0123]\n$/'); # print login
$t->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET\n\n");
$t->waitfor('/Authentication accepted/'); # waitfor auth accepted
+1 -1
View File
@@ -15,7 +15,7 @@ write = command
[listencron]
secret = 1234
read = system,call,log,verbose,command,agent,user
read = system,call,log,verbose,command,agent,user,dtmf
;read = all
write = command
+14 -1
View File
@@ -3267,6 +3267,19 @@ PRIMARY KEY (url_id),
KEY vicidial_url_multi_campaign_id_key (campaign_id)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
CREATE TABLE vicidial_dtmf_log (
dtmf_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
dtmf_time DATETIME,
channel VARCHAR(100) NOT NULL,
server_ip VARCHAR(15) NOT NULL,
uniqueid VARCHAR(20) default '',
digit VARCHAR(1) default '',
direction ENUM('Received','Sent') default 'Received',
state ENUM('BEGIN','END') default 'BEGIN',
PRIMARY KEY (dtmf_id),
KEY vicidial_dtmf_uniqueid_key (uniqueid)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
ALTER TABLE vicidial_email_list MODIFY message text character set utf8;
@@ -3516,4 +3529,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1419',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1420',db_schema_update_date=NOW(),reload_timestamp=NOW();
+15
View File
@@ -202,3 +202,18 @@ KEY vicidial_url_multi_campaign_id_key (campaign_id)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
UPDATE system_settings SET db_schema_version='1419',db_schema_update_date=NOW() where db_schema_version < 1419;
CREATE TABLE vicidial_dtmf_log (
dtmf_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
dtmf_time DATETIME,
channel VARCHAR(100) NOT NULL,
server_ip VARCHAR(15) NOT NULL,
uniqueid VARCHAR(20) default '',
digit VARCHAR(1) default '',
direction ENUM('Received','Sent') default 'Received',
state ENUM('BEGIN','END') default 'BEGIN',
PRIMARY KEY (dtmf_id),
KEY vicidial_dtmf_uniqueid_key (uniqueid)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_unicode_ci;
UPDATE system_settings SET db_schema_version='1420',db_schema_update_date=NOW() where db_schema_version < 1420;