From 3c35d0133717451d55cd8a8f1c874726cc1fed1e Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 31 May 2019 17:32:43 +0000 Subject: [PATCH] Added experimental SIP event logging git-svn-id: svn://192.168.202.10@3106 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/UPGRADE | 5 + agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi | 168 +++- agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl | 152 ++++ agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl | 140 +++- agc_2-X/trunk/bin/ADMIN_update_server_ip.pl | 5 +- agc_2-X/trunk/bin/AST_flush_DBqueue.pl | 49 ++ agc_2-X/trunk/bin/AST_manager_sip_AMI2.pl | 772 ++++++++++++++++++ agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt | 170 ++++ .../conf_examples/extensions.conf.sample-13 | 25 +- .../docs/conf_examples/manager.conf.sample-13 | 9 + .../trunk/extras/MySQL_AST_CREATE_tables.sql | 74 +- agc_2-X/trunk/extras/sip_logging.patch | 50 ++ agc_2-X/trunk/extras/upgrade_2.14.sql | 73 ++ agc_2-X/trunk/install.pl | 6 +- agc_2-X/trunk/www/agc/vdc_db_query.php | 73 +- agc_2-X/trunk/www/vicidial/admin.php | 21 +- .../trunk/www/vicidial/help_documentation.txt | 3 +- 17 files changed, 1746 insertions(+), 49 deletions(-) create mode 100644 agc_2-X/trunk/bin/AST_manager_sip_AMI2.pl create mode 100644 agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt create mode 100644 agc_2-X/trunk/extras/sip_logging.patch diff --git a/agc_2-X/trunk/UPGRADE b/agc_2-X/trunk/UPGRADE index ee7ea57d..5c3075d5 100644 --- a/agc_2-X/trunk/UPGRADE +++ b/agc_2-X/trunk/UPGRADE @@ -409,6 +409,11 @@ OTHER CHANGES: to one specific report when they log in without seeing the admin web screen at all. Must be enabled in System Settings. +114. Added experimental SIP event logging. Requires patched Asteirsk 13 and + newer version of MySQL/MariaDB. Must be enabled in System Settings and + each dialer's astguiclient.conf/extensions.conf/manager.conf files + Read SIP_EVENT_LOGGING.txt doc for more details + diff --git a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi index 1f24f250..b58782a5 100644 --- a/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi +++ b/agc_2-X/trunk/agi/agi-VDAD_ALL_outbound.agi @@ -22,22 +22,21 @@ # ; - LB - Load Balance total system # ; - LO - Load Balance Overflow only (priority to home server) # ; - SO - Home server only -# ; 3. the sound file to play when doing a SURVEY, REMINDER, REMINDX campaign -# ; 4. the acceptible dtmf digits for a SURVEY -# ; 5. the out-opt digit for a SURVEY (must be in the digit map) -# ; 6. the sound file to play for a SURVEY when transfering to an agent -# ; 7. the sound file to play for a SURVEY when DNCing the call -# ; 8. OPTIN or OPTOUT: if OPTIN call is only sent to agent with button press +# ; 3. The Connected Line Name to solve CID Name change issues. +# ; 4. the sound file to play when doing a SURVEY, REMINDER, REMINDX campaign +# ; 5. the acceptible dtmf digits for a SURVEY +# ; 6. the out-opt digit for a SURVEY (must be in the digit map) +# ; 7. the sound file to play for a SURVEY when transfering to an agent +# ; 8. the sound file to play for a SURVEY when DNCing the call +# ; 9. OPTIN or OPTOUT: if OPTIN call is only sent to agent with button press # ; if OPTOUT call is sent to agent if no button press at all -# ; 9. the status that is use for a SURVEY when someone opts out +# ; 10. the status that is use for a SURVEY when someone opts out # ; if the status is DNC it will also add them to the internal dnc table # -# ;outbound VICIDIAL calls: +#; VICIDIAL_auto_dialer transfer script Load Balanced: #exten => 8368,1,AGI(agi://127.0.0.1:4577/call_log) -#exten => 8368,2,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB) -#exten => 8368,3,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB) -#exten => 8368,4,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB) -#exten => 8368,5,Hangup +#exten => 8368,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB-----${CONNECTEDLINE(name)}) +#exten => 8368,n,Hangup() # # ;outbound VICIDIAL SURVEY calls: #exten => 8366,1,AGI(agi://127.0.0.1:4577/call_log) @@ -46,7 +45,7 @@ #exten => 8366,4,AGI(agi-VDAD_ALL_outbound.agi,SURVEY-----LB-----US_pol_survey_hello-----1238-----8-----US_pol_survey_transfer-----US_thanks_no_contact-----OPTOUT-----DNC) #exten => 8366,5,Hangup # -# Copyright (C) 2018 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell LICENSE: AGPLv2 # # changes: # 80218-2027 - First Build @@ -119,12 +118,13 @@ # 170921-2007 - Fix for CALLID in beginning of recording filename # 170930-0913 - Added extension append options # 180926-2350 - Added _wait_time options for next_agent_call +# 190531-0901 - Changed dialplan inputs to accept connected-line name for CIDname validation, added SIP event processing # $script = 'agi-VDAD_ALL_outbound.agi'; $AGILOG = '0'; $mel=1; # Mysql Error Log enabled = 1 -$mysql_log_count=136; +$mysql_log_count=140; $one_mysql_log=0; use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second @@ -235,6 +235,21 @@ $AGI = new Asterisk::AGI; $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") or die "Couldn't connect to database: " . DBI->errstr; +############################################# +##### Gather system_settings ##### +$stmtA = "SELECT sip_event_logging 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; + $SSsip_event_logging = $aryA[0]; + } +$sthA->finish(); +########################################### + + ### Grab Server values from the database $stmtA = "SELECT voicemail_dump_exten,ext_context,answer_transfer_agent,local_gmt,asterisk_version,max_vicidial_trunks,agi_output,voicemail_dump_exten_no_inst FROM servers where server_ip = '$VARserver_ip';"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -283,13 +298,14 @@ if (length($ARGV[0])>1) @ARGV_vars = split(/-----/, $ARGV[0]); $call_handle_method = $ARGV_vars[0]; $agent_search_method = $ARGV_vars[1]; - $survey_first_audio_file = $ARGV_vars[2]; - $survey_dtmf_digits = $ARGV_vars[3]; - $survey_ni_digit = $ARGV_vars[4]; - $survey_opt_in_audio_file = $ARGV_vars[5]; - $survey_ni_audio_file = $ARGV_vars[6]; - $survey_no_response_action =$ARGV_vars[7]; - $survey_ni_status = $ARGV_vars[8]; + $connected_line_name = $ARGV_vars[2]; + $survey_first_audio_file = $ARGV_vars[3]; + $survey_dtmf_digits = $ARGV_vars[4]; + $survey_ni_digit = $ARGV_vars[5]; + $survey_opt_in_audio_file = $ARGV_vars[6]; + $survey_ni_audio_file = $ARGV_vars[7]; + $survey_no_response_action = $ARGV_vars[8]; + $survey_ni_status = $ARGV_vars[9]; } if ($call_handle_method !~ /NORMAL|TEST|BROADCAST|SURVEY|REMIND/) @@ -363,12 +379,99 @@ $survey_drop=0; $callerid =~ s/\"//gi; $callerid =~ s/ .*//gi; + +# check if callerid is valid +if ( !validate_cid_name( $callerid ) ) +{ + if ($AGILOG) {$agi_string = "CALLERID '$callerid' INVALID!!!!!!! Trying to use Connected Line Name '$connected_line_name'"; &agi_output;} + + if ( validate_cid_name( $connected_line_name ) ) + { + $callerid = $connected_line_name; + } + else + { + if ($AGILOG) {$agi_string = "Connected Line Name $connected_line_name is also invalid! This is bad."; &agi_output;} + } +} + $CIDlead_id = $callerid; $CIDlead_id = substr($CIDlead_id, 10, 10); $CIDlead_id = ($CIDlead_id + 0); if ($AGILOG) {$agi_string = "+++++ VDAD START : |$CIDlead_id|$now_date|$AST_ver|$priority|"; &agi_output;} + +##### BEGIN SIP event logging, if enabled in the system ##### +if ($SSsip_event_logging > 0) + { + # flag the vicidial_sip_event_recent record as undergoing processing + $stmtA = "UPDATE vicidial_sip_event_recent set processed='U' where caller_code='$callerid' LIMIT 1;"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01137'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "-- SIP-event recent check: |$affected_rows|$callerid|"; &agi_output;} + + if ($affected_rows > 0) + { + $stmtA = "SELECT invite_date,first_180_date,first_183_date,200_date,(200_date - invite_date) as dial,(first_180_date - invite_date) as prog,(first_180_date - invite_date) as pdd from vicidial_sip_event_recent where caller_code='$callerid' LIMIT 1;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArowsVSER=$sthA->rows; + $dbhP=$dbhA; $mysql_count='01138'; $MEL_aff_rows=$sthArowsLI; &mysql_error_logging; + if ($sthArowsVSER > 0) + { + @aryA = $sthA->fetchrow_array; + $invite_date = $aryA[0]; + $first_180_date = $aryA[1]; + $first_183_date = $aryA[2]; + $sip200_date = $aryA[3]; + $dial_time = $aryA[4]; + $time_to_progress = $aryA[5]; + $time_to_ring = $aryA[6]; + } + $sthA->finish(); + + if ($sthArowsVSER > 0) + { + if ( ($time_to_progress > 0) && ($time_to_progress != 'NULL') ) + { + $invite_to_ring = $time_to_progress; + $ring_to_final = ($dial_time - $invite_to_ring); + } + else + { + if ( ($time_to_ring > 0) && ($time_to_ring != 'NULL') ) + { + $invite_to_ring = $time_to_ring; + $ring_to_final = ($dial_time - $invite_to_ring); + } + else + { + $invite_to_ring = 0; + $ring_to_final = 0; + } + } + + # insert a record into the vicidial_log_extended_sip table for this call + $stmtA = "INSERT INTO vicidial_log_extended_sip SET call_date='$invite_date', caller_code='$callerid', invite_to_ring='$invite_to_ring', ring_to_final='$ring_to_final', invite_to_final='$dial_time', last_event_code='200' LIMIT 1;"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01139'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "-- SIP-event recent processed: |$affected_rows|$callerid|"; &agi_output;} + + # flag the vicidial_sip_event_recent record as processed + $stmtA = "UPDATE vicidial_sip_event_recent set processed='Y' where caller_code='$callerid' LIMIT 1;"; + if ($AGILOG) {$agi_string = "|$stmtA|"; &agi_output;} + $affected_rows = $dbhA->do($stmtA); + $dbhP=$dbhA; $mysql_count='01140'; $MEL_aff_rows=$affected_rows; &mysql_error_logging; + if ($AGILOG) {$agi_string = "-- SIP-event recent processed: |$affected_rows|$callerid|"; &agi_output;} + } + } + } +##### END SIP event logging, if enabled in the system ##### + + if ( ($channel =~ /Local/i) && ($AST_ver !~ /^1\.0\.8|^1\.0\.9/) ) { if ($AGILOG) {$agi_string = "+++++ VDAD START LOCAL CHANNEL: EXITING- $priority"; &agi_output;} @@ -4272,3 +4375,26 @@ sub trigger_transfer_process # close(Pout); # } } + + +# function to validate whether a CID Name is a Vicidial Call ID that we care about +sub validate_cid_name + { + my ($cid_name) = @_; + + # check if it is a valid CID Name + if ( + ( $cid_name =~ /DC\d\d\d\d\d\dW\d\d\d\d\d\d\d\d\d\dW/ ) || # 3way transfers + ( $cid_name =~ /M\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) || # Manual Dials + ( $cid_name =~ /V\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) || # Auto Dials + ( $cid_name =~ /Y\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) # Inbound Calls + ) + { + return 1; # if so return 1 for true + } + else + { + return 0; # if not return 0 for false + } + + } diff --git a/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl b/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl index 9fa394c1..c401230f 100644 --- a/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl +++ b/agc_2-X/trunk/bin/ADMIN_archive_log_tables.pl @@ -55,6 +55,7 @@ # 180410-1728 - Added vicidial_agent_function_log archiving # 180712-1641 - Added --wipe-all-being-archived AND --did-log-days options # 190318-1541 - Added vicidial_amd_log archiving +# 190531-0841 - Added vicidial_log_extended_sip archiving # $CALC_TEST=0; @@ -372,6 +373,19 @@ use DBI; $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") or die "Couldn't connect to database: " . DBI->errstr; +############################################# +##### Gather system_settings ##### +$stmtA = "SELECT sip_event_logging 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; + $SSsip_event_logging = $aryA[0]; + } +$sthA->finish(); +########################################### if (!$T) { @@ -449,6 +463,38 @@ if (!$T) } ##### END vicidial_log_extended_archive trim processing ##### + if ($SSsip_event_logging > 0) + { + ##### BEGIN vicidial_log_extended_sip_archive trim processing ##### + $stmtA = "SELECT count(*) from vicidial_log_extended_sip_archive;"; + $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_log_extended_sip_archive_count = $aryA[0]; + } + $sthA->finish(); + + if (!$Q) {print "Trimming vicidial_log_extended_sip_archive table... ($vicidial_log_extended_sip_archive_count)\n";} + + $rv = $sthA->err(); + if (!$rv) + { + $stmtA = "DELETE FROM vicidial_log_extended_sip_archive WHERE call_date < '$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_log_extended_sip_archive table \n";} + + $stmtA = "optimize table vicidial_log_extended_sip_archive;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + } + ##### END vicidial_log_extended_sip_archive trim processing ##### + } + ##### BEGIN vicidial_drop_log_archive trim processing ##### $stmtA = "SELECT count(*) from vicidial_drop_log_archive;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -856,6 +902,56 @@ if (!$T) ##### END vicidial_log_extended DAILY processing ##### + if ($SSsip_event_logging > 0) + { + ##### BEGIN vicidial_log_extended_sip DAILY processing ##### + $stmtA = "SELECT count(*) from vicidial_log_extended_sip;"; + $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_log_extended_sip_count = $aryA[0]; + } + $sthA->finish(); + + $stmtA = "SELECT count(*) from vicidial_log_extended_sip_archive;"; + $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_log_extended_sip_archive_count = $aryA[0]; + } + $sthA->finish(); + + if (!$Q) {print "\nProcessing vicidial_log_extended_sip table... ($vicidial_log_extended_sip_count|$vicidial_log_extended_sip_archive_count)\n";} + $stmtA = "INSERT IGNORE INTO vicidial_log_extended_sip_archive SELECT * from vicidial_log_extended_sip;"; + $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 inserted into vicidial_log_extended_sip_archive table \n";} + + $rv = $sthA->err(); + if (!$rv) + { + $stmtA = "DELETE FROM vicidial_log_extended_sip WHERE call_date < '$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_log_extended_sip table \n";} + + $stmtA = "optimize table vicidial_log_extended_sip;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + } + ##### END vicidial_log_extended_sip DAILY processing ##### + } + + ##### BEGIN vicidial_drop_log DAILY processing ##### $stmtA = "SELECT count(*) from vicidial_drop_log;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; @@ -1568,6 +1664,62 @@ if (!$T) } + if ($SSsip_event_logging > 0) + { + ##### vicidial_log_extended_sip + $stmtA = "SELECT count(*) from vicidial_log_extended_sip;"; + $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_log_extended_sip_count = $aryA[0]; + } + $sthA->finish(); + + $stmtA = "SELECT count(*) from vicidial_log_extended_sip_archive;"; + $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_log_extended_sip_archive_count = $aryA[0]; + } + $sthA->finish(); + + if (!$Q) {print "\nProcessing vicidial_log_extended_sip table... ($vicidial_log_extended_sip_count|$vicidial_log_extended_sip_archive_count)\n";} + $stmtA = "INSERT IGNORE INTO vicidial_log_extended_sip_archive SELECT * from vicidial_log_extended_sip;"; + $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 inserted into vicidial_log_extended_sip_archive table \n";} + + $rv = $sthA->err(); + if (!$rv) + { + if ($wipe_all > 0) + {$stmtA = "DELETE FROM vicidial_log_extended_sip;";} + else + {$stmtA = "DELETE FROM vicidial_log_extended_sip WHERE call_date < '$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_log_extended_sip table \n";} + + $stmtA = "optimize table vicidial_log_extended_sip;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + + $stmtA = "optimize table vicidial_log_extended_sip_archive;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + } + } + + ##### vicidial_drop_log $stmtA = "SELECT count(*) from vicidial_drop_log;"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; diff --git a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl index af8f97d0..447866c8 100644 --- a/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl +++ b/agc_2-X/trunk/bin/ADMIN_keepalive_ALL.pl @@ -135,9 +135,10 @@ # 180930-1007 - Added more allowed codecs to conf file generation # 181028-1451 - Added vicidial_list stuck QUEUE reset at TEoD # 190220-2258 - Added flushing of vicidial_sessions_recent table +# 190530-1411 - Added SIP logger code # -$build = '190220-2258'; +$build = '190530-1411'; $DB=0; # Debug flag $teodDB=0; # flag to log Timeclock End of Day processes to log file @@ -165,6 +166,7 @@ $now_date = "$year-$mon-$mday $hour:$min:$sec"; $today_start = "$year-$mon-$mday 00:00:00"; $today_date = "$year-$mon-$mday"; $reset_test = "$hour$min"; +$wday_now = $wday; ### calculate the date and time for slightly less than 24 hours ago $secX = time(); @@ -388,6 +390,7 @@ foreach(@conf) # 8 - ip_relay for blind monitoring\n"; # 9 - Timeclock auto logout\n"; # E - Email parser script +# S - SIP Logger # - Other setting are set by configuring them in the database # Customized Variables @@ -403,7 +406,7 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA ##### Get the settings from system_settings ##### -$stmtA = "SELECT sounds_central_control_active,active_voicemail_server,custom_dialplan_entry,default_codecs,generate_cross_server_exten,voicemail_timezones,default_voicemail_timezone,call_menu_qualify_enabled,allow_voicemail_greeting,reload_timestamp,meetme_enter_login_filename,meetme_enter_leave3way_filename,allow_chats,enable_auto_reports,enable_drop_lists,expired_lists_inactive FROM system_settings;"; +$stmtA = "SELECT sounds_central_control_active,active_voicemail_server,custom_dialplan_entry,default_codecs,generate_cross_server_exten,voicemail_timezones,default_voicemail_timezone,call_menu_qualify_enabled,allow_voicemail_greeting,reload_timestamp,meetme_enter_login_filename,meetme_enter_leave3way_filename,allow_chats,enable_auto_reports,enable_drop_lists,expired_lists_inactive,sip_event_logging FROM system_settings;"; # print "$stmtA\n"; $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; @@ -427,6 +430,7 @@ if ($sthArows > 0) $SSenable_auto_reports = $aryA[13]; $SSenable_drop_lists = $aryA[14]; $SSexpired_lists_inactive = $aryA[15]; + $SSsip_event_logging = $aryA[16]; } $sthA->finish(); if ($DBXXX > 0) {print "SYSTEM SETTINGS: $sounds_central_control_active|$active_voicemail_server|$SScustom_dialplan_entry|$SSdefault_codecs\n";} @@ -472,6 +476,7 @@ else $email_inbound=0; $AST_VDauto_dial_FILL=0; $ip_relay=0; + $sip_logger=0; $timeclock_auto_logout=0; $runningAST_update=0; $runningAST_send=0; @@ -485,6 +490,7 @@ else $runningAST_conf_3way=0; $runningemail_inbound=0; $runningASTERISK=0; + $runningsip_logger=0; $AST_conf_3way=0; if ($VARactive_keepalives =~ /1/) @@ -537,6 +543,11 @@ else $email_inbound=1; if ($DB) {print "Check to see if email parser should run\n";} } + if ($VARactive_keepalives =~ /S/) + { + $sip_logger=1; + if ($DB) {print "Check to see if sip logger should run\n";} + } if ($cu3way > 0) { $AST_conf_3way=1; @@ -590,6 +601,11 @@ else $runningAST_listen++; if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";} } + if ($psline[1] =~ /$REGhome\/AST_manager_sip_AMI2\.pl/) + { + $runningsip_logger++; + if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";} + } if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/) { $runningAST_VDauto_dial++; @@ -702,7 +718,8 @@ else ( ($AST_VDauto_dial_FILL > 0) && ($runningAST_VDauto_dial_FILL < 1) ) || ( ($ip_relay > 0) && ($runningip_relay < 1) ) || ( ($AST_conf_3way > 0) && ($runningAST_conf_3way < 1) ) || - ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) + ( ($email_inbound > 0) && ($runningemail_inbound < 1) ) || + ( ($sip_logger > 0) && ($runningsip_logger < 1) ) ) { @@ -745,6 +762,11 @@ else $runningAST_listen++; if ($DB) {print "AST_listen RUNNING: |$psline[1]|\n";} } + if ($psline[1] =~ /$REGhome\/AST_manager_sip_AMI2\.pl/) + { + $runningsip_logger++; + if ($DB) {print "SIP Logger RUNNING: |$psline[1]|\n";} + } if ($psline[1] =~ /$REGhome\/AST_VDauto_dial\.pl/) { $runningAST_VDauto_dial++; @@ -847,6 +869,18 @@ else `/usr/bin/screen -S ASTVDauto -X log`; } } + if ( ($sip_logger > 0) && ($runningsip_logger < 1) && ($SSsip_event_logging > 0) ) + { + if ($DB) {print "starting SIP Logger...\n";} + # add a '-L' to the command below to activate logging + `/usr/bin/screen -d -m -S ASTSIPlogger $PATHhome/AST_manager_sip_AMI2.pl $debug_string`; + if ($megaDB) + { + `/usr/bin/screen -S ASTSIPlogger -X logfile $PATHlogs/ASTVDauto-screenlog.0`; + `/usr/bin/screen -S ASTSIPlogger -X log`; + } + } + if ( ($AST_VDremote_agents > 0) && ($runningAST_VDremote_agents < 1) ) { if ($DB) {print "starting AST_VDremote_agents...\n";} @@ -1820,6 +1854,106 @@ if ($timeclock_end_of_day_NOW > 0) $i++; } $sthA->finish(); + + + ##### BEGIN roll sip_event logs into one of the 7-day archive tables + if ($SSsip_event_logging > 0) + { + $TEMPvicidial_sip_event_log = "vicidial_sip_event_log_$wday_now"; + if (!$Q) {print "\nRolling of vicidial_sip_event_log table into daily archive table($TEMPvicidial_sip_event_log)...\n";} + $stmtA = "DELETE FROM $TEMPvicidial_sip_event_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows = $sthA->rows; + $event_string = "$sthArows rows deleted from $TEMPvicidial_sip_event_log table"; + if (!$Q) {print "$event_string \n";} + if ($teodDB) {&teod_logger;} + + $stmtA = "optimize table $TEMPvicidial_sip_event_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $event_string = "$TEMPvicidial_sip_event_log table optimized"; + if (!$Q) {print "$event_string \n";} + if ($teodDB) {&teod_logger;} + + $stmtA = "INSERT IGNORE INTO $TEMPvicidial_sip_event_log SELECT * from vicidial_sip_event_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows = $sthA->rows; + $event_string = "$sthArows rows inserted into $TEMPvicidial_sip_event_log table"; + if (!$Q) {print "$event_string \n";} + if ($teodDB) {&teod_logger;} + + $rv = $sthA->err(); + if (!$rv) + { + $stmtA = "DELETE FROM vicidial_sip_event_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows = $sthA->rows; + $event_string = "$sthArows rows deleted from vicidial_sessions_recent table"; + if (!$Q) {print "$event_string \n";} + if ($teodDB) {&teod_logger;} + + $stmtA = "optimize table vicidial_sip_event_log;"; + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $event_string = "vicidial_sip_event_log table optimized"; + if (!$Q) {print "$event_string \n";} + if ($teodDB) {&teod_logger;} + + $stmtC = "ALTER TABLE vicidial_sip_event_log AUTO_INCREMENT = 1;"; + if($DBX){print STDERR "\n|$stmtC|\n";} + $Caffected_rows = $dbhC->do($stmtC); + $event_string = "vicidial_sip_event_log AUTO_INCREMENT reset to 1($Caffected_rows)"; + if (!$Q) {print "$event_string \n";} + if ($teodDB) {&teod_logger;} + } + + # get details on today archives and update archive details table + $vsel_count=0; + $stmtA = "SELECT count(*) FROM $TEMPvicidial_sip_event_log;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $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; + $vsel_count = $aryA[0]; + } + $stmtA = "SELECT event_date FROM $TEMPvicidial_sip_event_log order by sip_event_id LIMIT 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $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; + $vsel_start = $aryA[0]; + } + + $stmtA = "SELECT event_date FROM $TEMPvicidial_sip_event_log order by sip_event_id desc LIMIT 1;"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $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; + $vsel_end = $aryA[0]; + } + + $stmtA = "INSERT INTO vicidial_sip_event_archive_details SET wday='$wday_now',start_event_date='$vsel_start',end_event_date='$vsel_end',record_count='$vsel_count' ON DUPLICATE KEY UPDATE start_event_date='$vsel_start',end_event_date='$vsel_end',record_count='$vsel_count';"; + if($DBX){print STDERR "\n|$stmtA|\n";} + $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; + $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; + $sthArows = $sthA->rows; + $event_string = "$sthArows rows updated in vicidial_sip_event_archive_details table"; + if (!$Q) {print "$event_string \n";} + if ($teodDB) {&teod_logger;} + } + ##### END roll sip_event logs into one of the 7-day archive tables } } diff --git a/agc_2-X/trunk/bin/ADMIN_update_server_ip.pl b/agc_2-X/trunk/bin/ADMIN_update_server_ip.pl index f081883c..ec61ad60 100644 --- a/agc_2-X/trunk/bin/ADMIN_update_server_ip.pl +++ b/agc_2-X/trunk/bin/ADMIN_update_server_ip.pl @@ -6,7 +6,7 @@ # astguiclient.conf file to reflect a change in IP address. The script will # automatically default to the first eth address in the ifconfig output. # -# Copyright (C) 2018 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell LICENSE: AGPLv2 # # CHANGELOG # 71205-2144 - Added display of extensions.conf example for call routing @@ -16,6 +16,7 @@ # 100428-0943 - Added DB custom user/pass fields # 150312-1000 - Added ExpectedDBSchema # 180928-1958 - Added update of report_server, active_twin_server_ip and active_voicemail_server, issue #1109 +# 190530-1517 - Added mising commented-out keepalives in conf file # # default path to astguiclient configuration file: @@ -355,6 +356,8 @@ print conf "# 6 - FastAGI_log\n"; print conf "# 7 - AST_VDauto_dial_FILL (only for multi-server, this must only be on one server)\n"; print conf "# 8 - ip_relay (used for blind agent monitoring)\n"; print conf "# 9 - Timeclock auto logout\n"; +print conf "# E - Email processor, (If multi-server system, this must only be on one server)\n"; +print conf "# S - SIP Logger (Patched Asterisk 13 required)\n"; print conf "VARactive_keepalives => $VARactive_keepalives\n"; print conf "\n"; print conf "# Asterisk version VICIDIAL is installed for\n"; diff --git a/agc_2-X/trunk/bin/AST_flush_DBqueue.pl b/agc_2-X/trunk/bin/AST_flush_DBqueue.pl index d76342a9..373f5c6f 100644 --- a/agc_2-X/trunk/bin/AST_flush_DBqueue.pl +++ b/agc_2-X/trunk/bin/AST_flush_DBqueue.pl @@ -28,9 +28,11 @@ # 181003-2115 - Added optimize of cid_channels_recent_ tables # 190214-1758 - Fix for cid_recent_ table optimization issue # 190222-1321 - Added optional flushing of vicidial_sessions_recent table +# 190503-1606 - Added flushing of vicidial_sip_event_recent table # $session_flush=0; +$SSsip_event_logging=0; ### begin parsing run-time options ### if (length($ARGV[0])>1) @@ -127,6 +129,17 @@ if ($min < 10) {$min = "0$min";} if ($sec < 10) {$sec = "0$sec";} $SQLdate_NEG_2min="$year-$mon-$mday $hour:$min:$sec"; +($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time() - ($purge_seconds * 2)); +$year = ($year + 1900); +$yy = $year; $yy =~ s/^..//gi; +$mon++; +if ($mon < 10) {$mon = "0$mon";} +if ($mday < 10) {$mday = "0$mday";} +if ($hour < 10) {$hour = "0$hour";} +if ($min < 10) {$min = "0$min";} +if ($sec < 10) {$sec = "0$sec";} +$SQLdate_NEG_2hour="$year-$mon-$mday $hour:$min:$sec"; + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time() - $purge_seconds); $year = ($year + 1900); $yy = $year; $yy =~ s/^..//gi; @@ -216,6 +229,18 @@ if ($sthArows > 0) } $sthA->finish(); +### Grab system_settings values from the database +$stmtA = "SELECT sip_event_logging FROM system_settings limit 1;"; +$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; + $SSsip_event_logging = $aryA[0]; + } +$sthA->finish(); + if ($SYSLOG) {$flush_time = $SQLdate_NEG_1hour;} else @@ -246,6 +271,14 @@ if($DB){print STDERR "\n|$stmtA|\n";} if (!$T) { $affected_rows = $dbhA->do($stmtA);} if (!$Q) {print " - cid_channels_recent flush: $affected_rows rows\n";} +if ($SSsip_event_logging > 0) + { + $stmtA = "DELETE from vicidial_sip_event_recent where invite_date < '$SQLdate_NEG_2hour';"; + if($DB){print STDERR "\n|$stmtA|\n";} + if (!$T) { $affected_rows = $dbhA->do($stmtA);} + if (!$Q) {print " - vicidial_sip_event_recent flush: $affected_rows rows\n";} + } + $stmtA = "OPTIMIZE table vicidial_manager;"; if($DB){print STDERR "\n|$stmtA|\n";} if (!$T) @@ -315,6 +348,22 @@ if (!$T) } if (!$Q) {print " - OPTIMIZE cid_channels_recent \n";} +if ($SSsip_event_logging > 0) + { + $stmtA = "OPTIMIZE table vicidial_sip_event_recent;"; + 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_sip_event_recent \n";} + } + $stmtA = "OPTIMIZE table vicidial_live_agents;"; if($DB){print STDERR "\n|$stmtA|\n";} diff --git a/agc_2-X/trunk/bin/AST_manager_sip_AMI2.pl b/agc_2-X/trunk/bin/AST_manager_sip_AMI2.pl new file mode 100644 index 00000000..0b488c3e --- /dev/null +++ b/agc_2-X/trunk/bin/AST_manager_sip_AMI2.pl @@ -0,0 +1,772 @@ +#!/usr/bin/perl +# +# AST_manager_sip_AMI2.pl version 2.14 +# +# DESCRIPTION: +# connects to the Asterisk Manager Interface version 2 and inserts records into +# the vicidial_sip_log for SIPInvite and SIPResponse events. +# +# Copyright (C) 2019 Matt Florell LICENSE: AGPLv2 +# +# CHANGES +# 190528-1304 - Copied AST_manager_listen_AMI2.pl to make the initial version +# + +# constants +$DB=0; # Debug flag, set to 0 for no debug messages, lots of output +$DBX=0; +$full_listen_log=0; # set to 1 to log all output to log file +$run_check=1; # concurrency check +$last_keepalive_epoch = time(); +$keepalive_skips=0; +$ami_user='sipcron'; + +### begin parsing run-time options ### +if (length($ARGV[0])>1) + { + $i=0; + while ($#ARGV >= $i) + { + $args = "$args $ARGV[$i]"; + $i++; + } + + if ($args =~ /--help/i) + { + print "allowed run time options:\n"; + print " [--test] = test\n"; + print " [--debug] = verbose debug messages\n"; + print " [--debugX] = Extra-verbose debug messages\n"; + print " [--help] = this screen\n"; + print "\n"; + exit; + } + else + { + if ($args =~ /--debug/i) + { + $DB=1; # Debug flag + print "\n----- DEBUGGING ENABLED -----\n\n"; + } + if ($args =~ /--debugX/i) + { + $DBX=1; + print "\n----- SUPER-DUPER DEBUGGING -----\n\n"; + } + if ($args =~ /--test/i) + { + $TEST=1; + $T=1; + } + } + } +### end parsing run-time options ### + +# default path to astguiclient configuration file: +$PATHconf = '/etc/astguiclient.conf'; + +open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n"; +@conf = ; +close(conf); +$i=0; +foreach(@conf) + { + $line = $conf[$i]; + $line =~ s/ |>|\n|\r|\t|\#.*|;.*//gi; + if ($line =~ /^PATHhome/) {$PATHhome = $line; $PATHhome =~ s/.*=//gi;} + if ($line =~ /^PATHlogs/) {$PATHlogs = $line; $PATHlogs =~ s/.*=//gi;} + if ($line =~ /^PATHagi/) {$PATHagi = $line; $PATHagi =~ s/.*=//gi;} + if ($line =~ /^PATHweb/) {$PATHweb = $line; $PATHweb =~ s/.*=//gi;} + if ($line =~ /^PATHsounds/) {$PATHsounds = $line; $PATHsounds =~ s/.*=//gi;} + if ($line =~ /^PATHmonitor/) {$PATHmonitor = $line; $PATHmonitor =~ s/.*=//gi;} + if ($line =~ /^VARserver_ip/) {$VARserver_ip = $line; $VARserver_ip =~ s/.*=//gi;} + if ($line =~ /^VARDB_server/) {$VARDB_server = $line; $VARDB_server =~ s/.*=//gi;} + if ($line =~ /^VARDB_database/) {$VARDB_database = $line; $VARDB_database =~ s/.*=//gi;} + if ($line =~ /^VARDB_user/) {$VARDB_user = $line; $VARDB_user =~ s/.*=//gi;} + if ($line =~ /^VARDB_pass/) {$VARDB_pass = $line; $VARDB_pass =~ s/.*=//gi;} + if ($line =~ /^VARDB_port/) {$VARDB_port = $line; $VARDB_port =~ s/.*=//gi;} + $i++; + } + +# Customized Variables +$server_ip = $VARserver_ip; # Asterisk server IP + +if (!$VARDB_port) {$VARDB_port='3306';} + +&get_time_now; + +#use lib './lib', '../lib'; +use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second +use DBI; +use Net::Telnet (); +use Switch; +#use String::Escape qw( backslash unbackslash ); + +$module = 'String::Escape qw( backslash unbackslash )'; +$bs_loaded=0; +if (try_load($module)) + { + $bs_loaded=1; + } + +$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass") +or die "Couldn't connect to database: " . DBI->errstr; + +### Grab Server values from the database +$stmtA = "SELECT telnet_host,telnet_port,ASTmgrUSERNAME,ASTmgrSECRET,ASTmgrUSERNAMEupdate,ASTmgrUSERNAMElisten,ASTmgrUSERNAMEsend,max_vicidial_trunks,answer_transfer_agent,local_gmt,ext_context,vd_server_logs,asterisk_version FROM servers where server_ip = '$server_ip';"; +$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; +$sthA->execute or die "executing: $stmtA ", $dbhA->errstr; +$sthArows=$sthA->rows; +if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $DBtelnet_host = $aryA[0]; + $DBtelnet_port = $aryA[1]; + $DBASTmgrUSERNAME = $aryA[2]; + $DBASTmgrSECRET = $aryA[3]; + $DBASTmgrUSERNAMEupdate = $aryA[4]; + $DBASTmgrUSERNAMElisten = $aryA[5]; + $DBASTmgrUSERNAMEsend = $aryA[6]; + $DBmax_vicidial_trunks = $aryA[7]; + $DBanswer_transfer_agent= $aryA[8]; + $DBSERVER_GMT = $aryA[9]; + $DBext_context = $aryA[10]; + $DBvd_server_logs = $aryA[11]; + $asterisk_version = $aryA[12]; + 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 ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + } +$sthA->finish(); + +if (!$telnet_port) {$telnet_port = '5038';} + +$event_string='LOGGED INTO MYSQL SERVER ON 1 CONNECTION|'; +&event_logger; + +### concurrency check (SCREEN uses script path, so check for more than 2 entries) +if ($run_check > 0) + { + my $grepout = `/bin/ps ax | grep $0 | grep -v grep | grep -v '/bin/sh'`; + my $grepnum=0; + $grepnum++ while ($grepout =~ m/\n/g); + if ($grepnum > 2) + { + if ($DB) {print "I am not alone! Another $0 is running! Exiting...\n";} + $event_string = "I am not alone! Another $0 is running! Exiting..."; + &event_logger; + exit; + } + } + + +$event_string="STARTING NEW MANAGER TELNET CONNECTION||ATTEMPT|ONE DAY INTERVAL:$one_day_interval|"; +&event_logger; + +$max_buffer = 4*1024*1024; # 4 meg buffer + +### connect to asterisk manager through telnet +$tn = new Net::Telnet ( + Port => $telnet_port, + Prompt => '/\r\n/', + Output_record_separator => "\n\n", + Max_buffer_length => $max_buffer, + Telnetmode => 0, +); + +$LItelnetlog = "$PATHlogs/sip_event_telnet_log.txt"; # uncomment for telnet log +#$fh = $tn->dump_log("$LItelnetlog"); # uncomment for telnet log + +#if (length($ASTmgrUSERNAMElisten) > 3) {$telnet_login = $ASTmgrUSERNAMElisten;} +#else {$telnet_login = $ASTmgrUSERNAME;} +$telnet_login = $ami_user; + +$tn->open("$telnet_host"); +$tn->waitfor('/Asterisk Call Manager\//'); + +# get the AMI version number +$ami_version = $tn->getline(Errmode => Return, Timeout => 1,); +$ami_version =~ s/\n//gi; +print "----- AMI Version $ami_version -----\n"; + +# Login +$tn->print("Action: Login\nUsername: $telnet_login\nSecret: $ASTmgrSECRET"); +$tn->waitfor('/Authentication accepted/'); # waitfor auth accepted + +$tn->buffer_empty; + +$event_string="STARTING NEW MANAGER TELNET CONNECTION|$telnet_login|CONFIRMED CONNECTION|AMI Version $ami_version|ONE DAY INTERVAL:$one_day_interval|"; +&event_logger; + +# initalizing timing variables; +$loop_time = 1*100*1000; # each loop show take 10 hundredths of a second +$sleep_micro_sec = 0; # time to actually sleep in micro seconds +$begin_sec = 0; # the seconds at the beginning of the loop +$begin_micro_sec = 0; # the microseconds at the beginning of the loop +$end_sec = 0; # the seconds at the end of the loop +$end_micro_sec = 0; # the microseconds at the end of the loop +$sleep_diff = 0; # how off the sleep actually was + +$last_keep_alive_epoch = time(); +$last_partial_keep_alive_epoch = $last_keep_alive_epoch; +$last_event_epoch = $last_keep_alive_epoch; +$keep_alive_sec = 30; +$keep_alive_skips = 0; +$keep_alive_response = 1; +$keep_alive_no_responses = 0; + +%ast_ver_str = parse_asterisk_version($asterisk_version); +if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 13)) + { + print "Asterisk version too low for this script. Exiting.\n\n\n"; + $event_string = "Asterisk version too low for this script. Exiting."; + &event_logger; + exit; + } +else + { + ### BEGIN manager event handling for asterisk version >= 13 + $endless_loop = 1; + while($endless_loop > 0) + { + $breakout = 1; + $record_line = ''; + %event_hash = (); + + # get an entire record + ( $read_input_buf, $match ) = $tn->waitfor(Errmode => Return, Timeout => 1, Match => "/\n\n/" ); + + chomp( $read_input_buf ); + + if (($DBX) && ($bs_loaded) && (length($read_input_buf) > 0)) { print "|read|" . backslash( $read_input_buf ) . "|\n"; } + + if (($DBX) && ($bs_loaded) && (length($read_input_buf) > 0)) { print "|match|" . backslash( $match ) . "|\n"; } + + # check if there were any errors + $msg=''; + $msg = $tn->errmsg; + if ( ( $msg ne '' ) && ( $msg !~ /pattern match timed-out/i ) ) + { + if ($msg =~ /filehandle isn\'t open/i) + { + # we have lost connection + $endless_loop=0; + $one_day_interval=0; + print "ERRMSG: |$msg|\n"; + print "\nAsterisk server shutting down, PROCESS KILLED... EXITING\n\n"; + $event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|$msg|"; + &event_logger; + } + else + { + # something happened + print "ERRMSG: |$msg|\n"; + } + } + else + { + @lines = split( /\n/, $read_input_buf ); + $line_log=''; + foreach my $line ( @lines ) + { + $line_log .= "$line\n"; + # add the line to the hash + ($key,$value) = split( /: /, $line ); + if ($key ne "") + { + $value =~ s/\n//gi; # remove new lines + $value =~ s/^ +//gi; # remove leading white space + $value =~ s/ +$//gi; # remove trailing white space + $event_hash{"$key"} = $value; + } + } + if ($full_listen_log > 0) + { + $manager_string="$line_log"; + &manager_output_logger; + } + } + + + $keep_alive_epoch = time(); + + # take certain actions every second + if ( $keep_alive_epoch - $last_partial_keep_alive_epoch >= 1 ) + { + $last_partial_keep_alive_epoch = $keep_alive_epoch; + + ### check if we are getting close to filling the buffer + if ( $buf_len > ($max_buffer * 0.9) ) + { + if ($DB) { print "WARNING: BUFFER 90% full!!!! Purging it so we keep running.";} + $manager_string="WARNING: BUFFER 90% full!!!! Purging it so we keep running."; + &manager_output_logger; + + # purge the buffer + $tn->buffer_empty; + } + + ### Grab Server values from the database + ### Also keeps DB connection alive + $stmtA = "SELECT 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; + if ($sthArows > 0) + { + @aryA = $sthA->fetchrow_array; + $DBvd_server_logs = $aryA[0]; + if ($DBvd_server_logs =~ /Y/) {$SYSLOG = '1';} + else {$SYSLOG = '0';} + } + $sthA->finish(); + + ### putting a blank file called "listenmgr.kill" in a directory will automatically safely kill this program + if ( -e "$PATHhome/listenmgr.kill" ) + { + unlink("$PATHhome/listenmgr.kill"); + $endless_loop=0; + $one_day_interval=0; + print "\nPROCESS KILLED MANUALLY... EXITING\n\n"; + } + + ### no response to our last keep alive + if ( $keep_alive_response == 0 ) + { + $response_wait = $keep_alive_epoch - $last_keep_alive_epoch; + if($DB) { print "No response to keep alive in $response_wait seconds.\n"; } + } + + if ( $keep_alive_no_responses > 10 ) + { + if($DB) { print "$keep_alive_no_responses failed to get a response. Exiting!!!" } + $endless_loop=0; + $one_day_interval=0; + } + + ### check if it has been 40 seconds sense the last keep alive + &get_time_now; + if ( $keep_alive_epoch - $last_event_epoch >= $keep_alive_sec ) + { + if ( $keep_alive_epoch - $last_keep_alive_epoch >= $keep_alive_sec ) + { + ### if so send an AMI command to keep the connection alive + $keep_alive_skips = 0; + + if ( $keep_alive_response == 0 ) { $keep_alive_no_responses++; } + + $keep_alive_response = 0; + + $keep_alive_string = "Action: Ping"; + + $tn->print($keep_alive_string); + + $msg = $tn->errmsg; + + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + $output_size = @keep_alive_output; + + if($DB) { print "++++++++++++++++sending keepalive |$keep_alive_type|em:$msg|$output_size|$endless_loop|$now_date|$buf_len|$keep_alive_no_responses\n"; } + if($DBX) { print "---@keep_alive_output---\n"; } + + $manager_string="PROCESS: keepalive length: $output_size|$now_date"; + &manager_output_logger; + + $last_keep_alive_epoch = time(); + } + else + { + ### otherwise + $keep_alive_skips++; + + $buf_ref = $tn->buffer; + $buf_len = length( $$buf_ref ); + if($DB){print "----------------no keepalive transmit necessary ($keep_alive_skips in a row) $endless_loop|$now_date|$buf_len|$keep_alive_no_responses\n";} + + $manager_string="PROCESS: keepalive skip ($keep_alive_skips in a row)|$now_date"; + &manager_output_logger; + } + } + else + { + if($DB){ print "Event recieved within the last $keep_alive_sec seconds. No keep alive needed.\n"; } + } + } + + $event_hash{'AMIVersion'} = $ami_version; + $event_hash{'ServerIP'} = $server_ip; + + if ( ($DB) && ( keys %event_hash > 2 ) ) + { + &get_time_now; + print "\n\n$now_date|EVENT HASH:\n"; + foreach $key ( sort keys %event_hash ) + { + $value = $event_hash{"$key"}; + print " $key -> $value\n"; + } + print "\n"; + } + + $retcode = 1; + # make sure this is an event not a response + if (exists($event_hash{"Event"})) + { + # handle the event + $retcode = handle_event( %event_hash ); + $last_event_epoch = time(); + } + elsif ( ( exists($event_hash{"Response"}) ) && ( exists($event_hash{"Ping"}) ) ) + { + $keep_alive_response = 1; + $keep_alive_no_responses = 0; + } + + + # handle a shutdown + if ( $retcode == 0 ) + { + $endless_loop=0; + $one_day_interval=0; + print "\nAsterisk server shutting down, PROCESS KILLED... EXITING\n\n"; + $event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|"; + &event_logger; + } + } + + usleep(1*100*1000); + } + + + +if($DB){print "DONE... Exiting... Goodbye... See you later... Not really, initiating next loop...$one_day_interval left\n";} + +$event_string='HANGING UP|'; +&event_logger; + +@hangup = $tn->cmd(String => "Action: Logoff\n\n", Prompt => "/.*/", Errmode => Return, Timeout => 1); + +$tn->buffer_empty; +$tn->waitfor(Match => '/Message:.*\n\n/', Timeout => 10); +$ok = $tn->close; + + +$event_string='CLOSING DB CONNECTION|'; +&event_logger; + + +$dbhA->disconnect(); + + +if($DB){print "DONE... Exiting... Goodbye... See you later... Really I mean it this time\n";} + + +exit; + +# function to validate whether a CID Name is a Vicidial Call ID that we care about +sub validate_cid_name + { + my ($cid_name) = @_; + + # check if it is a valid CID Name + if ( + ( $cid_name =~ /DC\d\d\d\d\d\dW\d\d\d\d\d\d\d\d\d\dW/ ) || # 3way transfers + ( $cid_name =~ /M\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) || # Manual Dials + ( $cid_name =~ /V\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) || # Auto Dials + ( $cid_name =~ /Y\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d\d/) || # Inbound Calls + ( $cid_name =~ /^RINGAGENT|^RA_/ ) + ) + { + return 1; # if so return 1 for true + } + else + { + return 0; # if not return 0 for false + } + + } + +# function to return the valid callid +sub get_valid_callid + { + my ( $CallerIDName, $ConnectedLineName ) = @_; + + # remove everything after the space for Orex + if ( $CallerIDName =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$CallerIDName =~ s/ .*//gi;} + if ( $ConnectedLineName =~ /\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S\S/) {$ConnectedLineName =~ s/ .*//gi;} + + # if the CallerIDName variable does not have a valid Vicidial Call ID + # but the ConnectedLineName does use the ConnectedLineName + if ( !(validate_cid_name($CallerIDName)) && (validate_cid_name($ConnectedLineName)) ) + { + return $ConnectedLineName; + } + else + { + return $CallerIDName; + } + } + +# function to handle the AMI events +sub handle_event + { + my %event_hash = @_; + + switch ($event_hash{'Event'}) + { + # Asterisk is shutting down so should we + case "Shutdown" { return 0; } + + # DTMF event + case "DTMFBegin" { return handle_dtmf_begin_event( %event_hash ); } + case "DTMFEnd" { return handle_dtmf_end_event( %event_hash ); } + + # SIPInvite event + case "SIPInvite" { return handle_sip_invite ( %event_hash ); } + + # SIPResponse event + case "SIPResponse" { return handle_sip_response ( %event_hash ); } + + else { return 2; } + } + + } + +sub handle_sip_invite + { + + # Example Event: + # + # Event: SIPInvite + # Privilege: call,all + # Timestamp: 1559063934.425579 + # Channel: SIP/sgw2-000045be + # Uniqueid: 1559063934.53768 + # SIPCallID: 1c8e4edf5005173741e02b366aa31e02@208.38.155.226:5060 + # CallerIDName: V5281318520051804811 + # ConnectedLineName: V5281318520051804811 + + my %event_hash = @_; + + if ( + ( exists $event_hash{'Channel'} ) && + ( exists $event_hash{'Uniqueid'} ) && + ( exists $event_hash{'CallerIDName'} ) && + ( exists $event_hash{'ConnectedLineName'} ) && + ( exists $event_hash{'Timestamp'} ) && + ( exists $event_hash{'SIPCallID'} ) + ) + { + + # get the valid Vicidial Call ID + $call_id = get_valid_callid( $event_hash{'CallerIDName'}, $event_hash{'ConnectedLineName'} ); + + $stmtA = "INSERT INTO vicidial_sip_event_log SET caller_code ='$call_id', channel='$event_hash{'Channel'}', server_ip='$event_hash{'ServerIP'}', uniqueid='$event_hash{'Uniqueid'}', sip_call_id='$event_hash{'SIPCallID'}', event_date = FROM_UNIXTIME( $event_hash{'Timestamp'} ), sip_event = 'INVITE'"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->do($stmtA); + + + # update the vicidial_sip_event_recent table + + $stmtA = "INSERT INTO vicidial_sip_event_recent SET caller_code ='$call_id', channel='$event_hash{'Channel'}', server_ip='$event_hash{'ServerIP'}', uniqueid='$event_hash{'Uniqueid'}', invite_date = FROM_UNIXTIME( $event_hash{'Timestamp'} )"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->do($stmtA); + + return 1; + } + else + { + print STDERR "SIPInvite Event is missing fields ?!!!\n"; + return 3; + } + } + +sub handle_sip_response + { + + # Example Event: + # + # Event: SIPResponse + # Privilege: call,all + # Timestamp: 1559063934.426206 + # Response: 100 + # Channel: SIP/sgw2-000045be + # Uniqueid: 1559063934.53768 + # SIPCallID: 1c8e4edf5005173741e02b366aa31e02@208.38.155.226:5060 + # CallerIDName: V5281318520051804811 + # ConnectedLineName: V5281318520051804811 + + my %event_hash = @_; + + if ( + ( exists $event_hash{'Channel'} ) && + ( exists $event_hash{'Uniqueid'} ) && + ( exists $event_hash{'CallerIDName'} ) && + ( exists $event_hash{'ConnectedLineName'} ) && + ( exists $event_hash{'Timestamp'} )&& + ( exists $event_hash{'Response'} ) && + ( exists $event_hash{'SIPCallID'} ) + ) + { + + # get the valid Vicidial Call ID + $call_id = get_valid_callid( $event_hash{'CallerIDName'}, $event_hash{'ConnectedLineName'} ); + + $stmtA = "INSERT INTO vicidial_sip_event_log SET caller_code ='$call_id', channel='$event_hash{'Channel'}', server_ip='$event_hash{'ServerIP'}', uniqueid='$event_hash{'Uniqueid'}', sip_call_id='$event_hash{'SIPCallID'}', event_date = FROM_UNIXTIME( $event_hash{'Timestamp'} ), sip_event = '$event_hash{'Response'}'"; + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->do($stmtA); + + + # update the vicidial_sip_event_recent table + + # 100 Trying + if ( $event_hash{'Response'} == 100 ) { + $stmtA = "UPDATE vicidial_sip_event_recent SET first_100_date = IF( first_100_date IS NULL, FROM_UNIXTIME( $event_hash{'Timestamp'} ), first_100_date), last_100_date = FROM_UNIXTIME( $event_hash{'Timestamp'} ) where caller_code = '$call_id'"; + } + # 180 Ringing + if ( $event_hash{'Response'} == 180 ) { + $stmtA = "UPDATE vicidial_sip_event_recent SET first_180_date = IF( first_180_date IS NULL, FROM_UNIXTIME( $event_hash{'Timestamp'} ), first_180_date), last_180_date = FROM_UNIXTIME( $event_hash{'Timestamp'} ) where caller_code = '$call_id'"; + } + # 183 Session Progress + if ( $event_hash{'Response'} == 183 ) { + $stmtA = "UPDATE vicidial_sip_event_recent SET first_183_date = IF( first_183_date IS NULL, FROM_UNIXTIME( $event_hash{'Timestamp'} ), first_183_date), last_183_date = FROM_UNIXTIME( $event_hash{'Timestamp'} ) where caller_code = '$call_id'"; + } + # 200 OK + if ( $event_hash{'Response'} == 200 ) { + $stmtA = "UPDATE vicidial_sip_event_recent SET 200_date = FROM_UNIXTIME( $event_hash{'Timestamp'} ) where caller_code = '$call_id'"; + } + # Error Codes + if ( $event_hash{'Response'} >= 300 ) { + $stmtA = "UPDATE vicidial_sip_event_recent SET error_date = FROM_UNIXTIME( $event_hash{'Timestamp'} ) where caller_code = '$call_id'"; + } + + if($DB){print STDERR "|$stmtA|\n";} + $dbhA->do($stmtA); + + + return 1; + } + else + { + print STDERR "SIPResponse Event is missing fields ?!!!\n"; + return 3; + } + } + + +sub get_time_now #get the current date and time and epoch for logging call lengths and datetimes + { + ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); + $year = ($year + 1900); + $mon++; + if ($mon < 10) {$mon = "0$mon";} + if ($mday < 10) {$mday = "0$mday";} + if ($hour < 10) {$hour = "0$hour";} + if ($min < 10) {$min = "0$min";} + if ($sec < 10) {$sec = "0$sec";} + + $now_date_epoch = time(); + $now_date = "$year-$mon-$mday $hour:$min:$sec"; + $action_log_date = "$year-$mon-$mday"; + } + + + +sub event_logger + { + if ($SYSLOG) + { + ### open the log file for writing ### + open(Lout, ">>$PATHlogs/sip_event_process.$action_log_date") + || die "Can't open $PATHlogs/sip_event_process.$action_log_date: $!\n"; + print Lout "$now_date|$event_string|\n"; + close(Lout); + } + $event_string=''; + } + + + +sub manager_output_logger + { + if ($SYSLOG) + { + open(MOout, ">>$PATHlogs/sip_event.$action_log_date") + || die "Can't open $PATHlogs/sip_event.$action_log_date: $!\n"; + print MOout "$now_date|$manager_string|\n"; + close(MOout); + } + } + + +# subroutine to parse the asterisk version +# and return a hash with the various part +sub parse_asterisk_version + { + # grab the arguments + my $ast_ver_str = $_[0]; + + # get everything after the - and put it in $ast_ver_postfix + my @hyphen_parts = split( /-/ , $ast_ver_str ); + + my $ast_ver_postfix = $hyphen_parts[1]; + + # now split everything before the - up by the . + my @dot_parts = split( /\./ , $hyphen_parts[0] ); + + my %ast_ver_hash; + + if ( $dot_parts[0] <= 1 ) + { + %ast_ver_hash = ( + "major" => $dot_parts[0], + "minor" => $dot_parts[1], + "build" => $dot_parts[2], + "revision" => $dot_parts[3], + "postfix" => $ast_ver_postfix + ); + } + + # digium dropped the 1 from asterisk 10 but we still need it + if ( $dot_parts[0] > 1 ) + { + %ast_ver_hash = ( + "major" => 1, + "minor" => $dot_parts[0], + "build" => $dot_parts[1], + "revision" => $dot_parts[2], + "postfix" => $ast_ver_postfix + ); + } + + return ( %ast_ver_hash ); + } + +# try to load a module +sub try_load + { + my $mod = shift; + + eval("use $mod"); + + if ($@) + { + #print "\$@ = $@\n"; + return(0); + } + else + { + return(1); + } + } diff --git a/agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt b/agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt new file mode 100644 index 00000000..b0c8df03 --- /dev/null +++ b/agc_2-X/trunk/docs/SIP_EVENT_LOGGING.txt @@ -0,0 +1,170 @@ +SIP EVENT LOGGING DOC Started: 2019-05-30 Updated: 2019-05-30 + +!!!! THIS IS A WORK IN PROGRESS, NOT FINISHED !!!! + + + + +This document will go over the details of the new SIP event logging features that were added to VICIdial for use with patched versions of Asterisk 13 + +The purpose of this SIP event logging is to hopefully help to be able to better identify FAS(False Answer Supervision) and PDD(Post Dial Delay), as well as manual dial call progress updates to the agent. + + + +IMPORTANT DATABASE SOFTWARE NOTE!!! + +This new set of features is going to require database software from 2012 or newer, either MySQL 5.6(or higher) or MariaDB 5.3(or higher). That's when "microseconds" support was added in each. This is used for "DATETIME(6)" database fields that can store high-precision dates like so: "2019-05-30 15:29:22.374172". +Current VICIdial code requires only MySQL 5.1+(from 2005). + +For more details: +https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html +https://mariadb.com/kb/en/library/microseconds-in-mariadb/ + + + +IMPORTANT ASTERISK 13 PATCH NOTE!!! + +This set of features requires a patch to Asterisk 13. It is included in the VICIdial codebase here: "extras/sip_logging.patch". We do not currently have a patched version of Asterisk for distribution, but we will soon. + + + +IMPORTANT ASTERISK 13 CONF FILE NOTE!!! + +You will need to add lines to the /etc/asterisk/manager.conf file to allow for the new SIP messages to arrive from Asterisk: +# to see a complete version of this file, look at the "docs/conf_examples/manager.conf.sample-13" file + +# At the top(in the [general] section below "bindaddr = 0.0.0.0"): + +timestampevents = yes + +# At the bottom of the file, add: + +[sipcron] +secret = 1234 +read = call +write = command + +eventfilter=Event: SIPInvite +eventfilter=Event: SIPResponse + + + +IMPORTANT FEATURE ENABLING NOTE!!! + +To enable the SIP event logging listener script, you will need to add 'S' to the "VARactive_keepalives" line in "/etc/astguiclient.conf" file on each dialer that you want these new features to be activated on. + +You will also need to enable this feature in Admin -> System Settings + + + + +------------------- END OF IMPORTANT NOTES SECTION ----------------------------- + + + + +Scripts modified/added: +- bin/AST_manager_listen_AMI2.pl +- bin/ADMIN_keepalive_ALL.pl +- bin/ADMIN_update_server_ip.pl +- bin/AST_flush_DBqueue.pl +- bin/ADMIN_archive_log_tables.pl +- install.pl + + + + + + + + +-------- SQL CHANGES FOR DOCUMENTATION PURPOSES ONLY !!!!!!!!!! ---------------- + + +ALTER TABLE system_settings ADD sip_event_logging ENUM('0','1','2','3','4','5','6','7') default '0'; + +CREATE TABLE vicidial_sip_event_log ( +sip_event_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, +caller_code VARCHAR(30) NOT NULL, +channel VARCHAR(100), +server_ip VARCHAR(15), +uniqueid VARCHAR(20), +sip_call_id VARCHAR(256), +event_date DATETIME(6), +event VARCHAR(10), +index(caller_code), +index(event_date) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_sip_event_log_0 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_0 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_1 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_1 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_2 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_2 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_3 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_3 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_4 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_4 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_5 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_5 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_6 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_6 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; + +CREATE TABLE vicidial_sip_event_archive_details ( +wday TINYINT(1) UNSIGNED PRIMARY KEY NOT NULL, +start_event_date DATETIME(6), +end_event_date DATETIME(6), +record_count INT(9) UNSIGNED default '0' +) ENGINE=MyISAM; + +CREATE TABLE vicidial_sip_event_recent ( +caller_code VARCHAR(20) default '', +channel VARCHAR(100), +server_ip VARCHAR(15), +uniqueid VARCHAR(20), +invite_date DATETIME(6), +first_100_date DATETIME(6), +first_180_date DATETIME(6), +first_183_date DATETIME(6), +last_100_date DATETIME(6), +last_180_date DATETIME(6), +last_183_date DATETIME(6), +200_date DATETIME(6), +error_date DATETIME(6), +processed ENUM('N','Y','U') default 'N', +index(caller_code), +index(invite_date), +index(processed) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_log_extended_sip ( +call_date DATETIME(6), +caller_code VARCHAR(30) NOT NULL, +invite_to_ring DECIMAL(10,6) DEFAULT '0.000000', +ring_to_final DECIMAL(10,6) DEFAULT '0.000000', +invite_to_final DECIMAL(10,6) DEFAULT '0.000000', +last_event_code SMALLINT(3) default '0', +index(call_date), +index(caller_code) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_log_extended_sip_archive LIKE vicidial_log_extended_sip; +CREATE UNIQUE INDEX vlesa on vicidial_log_extended_sip_archive (caller_code,call_date); + + +MariaDB [asterisk]> SELECT * FROM vicidial_sip_event_log limit 10; ++--------------+----------------------+---------------------+----------------+-------------------+------------------------------------------------------+----------------------------+-----------+ +| sip_event_id | caller_code | channel | server_ip | uniqueid | sip_call_id | event_date | sip_event | ++--------------+----------------------+---------------------+----------------+-------------------+------------------------------------------------------+----------------------------+-----------+ +| 118753 | M5301113130609827030 | SIP/proxy1-00006875 | 192.168.201.77 | 1559229194.141493 | 4fb064702f741e0623b34dae6c8dd108@118.98.355.182:5060 | 2019-05-30 11:13:15.883335 | 183 | +| 118754 | M5301113120609740192 | SIP/proxy1-00006872 | 192.168.201.77 | 1559229192.141482 | 13de6de179d7d6b32858e4824f89cfbf@118.98.355.182:5060 | 2019-05-30 11:13:16.077451 | 183 | +| 118755 | M5301112560609853853 | SIP/proxy1-00006835 | 192.168.201.77 | 1559229176.141185 | 314c99633566c7ef6de23fb360156df2@118.98.355.182:5060 | 2019-05-30 11:13:16.079431 | 183 | +| 118756 | M5301113150609814022 | SIP/proxy1-0000687a | 192.168.201.77 | 1559229196.141522 | 2bcd9bfa0edef83f13f9aee22f6c0399@118.98.355.182:5060 | 2019-05-30 11:13:16.084397 | INVITE | +| 118757 | M5301113150609814022 | SIP/proxy1-0000687a | 192.168.201.77 | 1559229196.141522 | 2bcd9bfa0edef83f13f9aee22f6c0399@118.98.355.182:5060 | 2019-05-30 11:13:16.084989 | 100 | +| 118758 | M5301113150609814022 | SIP/proxy1-0000687a | 192.168.201.77 | 1559229196.141522 | 2bcd9bfa0edef83f13f9aee22f6c0399@118.98.355.182:5060 | 2019-05-30 11:13:16.085231 | 100 | +| 118759 | M5301112560609755273 | SIP/proxy1-00006838 | 192.168.201.77 | 1559229177.141198 | 6aa258ce5e0ba2085103ff2669d7e17b@118.98.355.182:5060 | 2019-05-30 11:13:16.244411 | 200 | +| 118760 | M5301113130609789654 | SIP/proxy1-00006874 | 192.168.201.77 | 1559229193.141488 | 7cd4c05546aeb95242b8d1196113ced8@118.98.355.182:5060 | 2019-05-30 11:13:16.291505 | 183 | +| 118761 | M5301113160609819452 | SIP/proxy1-0000687b | 192.168.201.77 | 1559229196.141527 | 5c3fc41572b6d91b04f1770d175f873d@118.98.355.182:5060 | 2019-05-30 11:13:16.292730 | INVITE | +| 118762 | M5301113160609819452 | SIP/proxy1-0000687b | 192.168.201.77 | 1559229196.141527 | 5c3fc41572b6d91b04f1770d175f873d@118.98.355.182:5060 | 2019-05-30 11:13:16.293336 | 100 | ++--------------+----------------------+---------------------+----------------+-------------------+------------------------------------------------------+----------------------------+-----------+ diff --git a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-13 b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-13 index 8d66705a..80fb9ec3 100644 --- a/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-13 +++ b/agc_2-X/trunk/docs/conf_examples/extensions.conf.sample-13 @@ -480,34 +480,35 @@ exten => _138331*.,n,Hangup() ; VICIDIAL_auto_dialer transfer script for no-agent campaigns: exten => 8364,1,AGI(agi://127.0.0.1:4577/call_log) -exten => 8364,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB) +exten => 8364,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB-----${CONNECTEDLINE(name)}) exten => 8364,n,Hangup() ; VICIDIAL_auto_dialer transfer script: exten => 8365,1,AGI(agi://127.0.0.1:4577/call_log) -exten => 8365,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----SO) +exten => 8365,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----SO-----${CONNECTEDLINE(name)}) exten => 8365,n,Hangup() ; VICIDIAL_auto_dialer transfer script SURVEY at beginning: exten => 8366,1,AGI(agi://127.0.0.1:4577/call_log) -exten => 8366,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMP-----LB) +exten => 8366,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMP-----LB-----${CONNECTEDLINE(name)}) exten => 8366,n,Hangup() ; VICIDIAL_auto_dialer transfer script Load Balance Overflow: exten => 8367,1,AGI(agi://127.0.0.1:4577/call_log) -exten => 8367,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LO) +exten => 8367,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LO-----${CONNECTEDLINE(name)}) exten => 8367,n,Hangup() ; VICIDIAL_auto_dialer transfer script Load Balanced: exten => 8368,1,AGI(agi://127.0.0.1:4577/call_log) -exten => 8368,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB) +exten => 8368,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB-----${CONNECTEDLINE(name)}) exten => 8368,n,Hangup() ; VICIDIAL_auto_dialer transfer script AMD with Load Balanced: exten => 8369,1,AGI(agi://127.0.0.1:4577/call_log) +exten => 8369,n,Playback(sip-silence) exten => 8369,n,AMD(2000,2000,1000,5000,120,50,4,256) exten => 8369,n,AGI(VD_amd.agi,${EXTEN}) -exten => 8369,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB) +exten => 8369,n,AGI(agi-VDAD_ALL_outbound.agi,NORMAL-----LB-----${CONNECTEDLINE(name)}) exten => 8369,n,Hangup() ; VICIDIAL auto-dial reminder script @@ -517,31 +518,33 @@ exten => 8372,n,Hangup() ; VICIDIAL SURVEY transfer script AMD with Load Balanced: exten => 8373,1,AGI(agi://127.0.0.1:4577/call_log) +exten => 8373,n,Playback(sip-silence) exten => 8373,n,AMD(2000,2000,1000,5000,120,50,4,256) exten => 8373,n,AGI(VD_amd.agi,${EXTEN}) -exten => 8373,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMP-----LB) +exten => 8373,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMP-----LB-----${CONNECTEDLINE(name)}) exten => 8373,n,Hangup() ; VICIDIAL SURVEY transfer script with Cepstral names: exten => 8374,1,AGI(agi://127.0.0.1:4577/call_log) -exten => 8374,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMPCEP-----LB) +exten => 8374,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMPCEP-----LB-----${CONNECTEDLINE(name)}) exten => 8374,n,Hangup() ; VICIDIAL SURVEY transfer script AMD with Cepstral variables: exten => 8375,1,AGI(agi://127.0.0.1:4577/call_log) +exten => 8375,n,Playback(sip-silence) exten => 8375,n,AMD(2000,2000,1000,5000,120,50,4,256) exten => 8375,n,AGI(VD_amd.agi,${EXTEN}) -exten => 8375,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMPCEP-----LB) +exten => 8375,n,AGI(agi-VDAD_ALL_outbound.agi,SURVEYCAMPCEP-----LB-----${CONNECTEDLINE(name)}) exten => 8375,n,Hangup() ; BETA VICIDIAL_auto_dialer transfer script Load Balanced: exten => 8377,1,AGI(agi://127.0.0.1:4577/call_log) exten => 8377,n,Set(LRct=1) exten => 8377,n,While($[${LRct} < 100]) -exten => 8377,n,AGI(agi-VDAD_ALL_outboundBETA.agi,NORMAL-----LB) +exten => 8377,n,AGI(agi-VDAD_ALL_outboundBETA.agi,NORMAL-----LB-----${CONNECTEDLINE(name)}) exten => 8377,n,Set(LRct=$[${LRct} + 1]) exten => 8377,n,EndWhile() -exten => 8377,n,AGI(agi-VDAD_ALL_outboundBETA.agi,NORMAL-----LB) +exten => 8377,n,AGI(agi-VDAD_ALL_outboundBETA.agi,NORMAL-----LB-----${CONNECTEDLINE(name)}) exten => 8377,n,Hangup() diff --git a/agc_2-X/trunk/docs/conf_examples/manager.conf.sample-13 b/agc_2-X/trunk/docs/conf_examples/manager.conf.sample-13 index d15467b1..eca9b484 100644 --- a/agc_2-X/trunk/docs/conf_examples/manager.conf.sample-13 +++ b/agc_2-X/trunk/docs/conf_examples/manager.conf.sample-13 @@ -2,6 +2,7 @@ enabled = yes port = 5038 bindaddr = 0.0.0.0 +timestampevents = yes [cron] secret = 1234 @@ -34,3 +35,11 @@ eventfilter=!Event: HangupRequest secret = 1234 read = command write = system,call,log,verbose,command,agent,user,originate + +[sipcron] +secret = 1234 +read = call +write = command + +eventfilter=Event: SIPInvite +eventfilter=Event: SIPResponse 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 1d9e9f1d..88ae5914 100644 --- a/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql +++ b/agc_2-X/trunk/extras/MySQL_AST_CREATE_tables.sql @@ -1814,7 +1814,8 @@ agent_logout_link ENUM('0','1','2','3','4') default '1', manual_dial_validation ENUM('0','1','2','3','4') default '0', mute_recordings ENUM('1','0') default '0', user_admin_redirect ENUM('1','0') default '0', -list_status_modification_confirmation ENUM('1','0') default '0' +list_status_modification_confirmation ENUM('1','0') default '0', +sip_event_logging ENUM('0','1','2','3','4','5','6','7') default '0' ) ENGINE=MyISAM; CREATE TABLE vicidial_campaigns_list_mix ( @@ -4046,6 +4047,57 @@ index (call_date), index (lead_id) ) ENGINE=MyISAM; +CREATE TABLE vicidial_sip_event_log ( +sip_event_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, +caller_code VARCHAR(30) NOT NULL, +channel VARCHAR(100), +server_ip VARCHAR(15), +uniqueid VARCHAR(20), +sip_call_id VARCHAR(256), +event_date DATETIME(6), +event VARCHAR(10), +index(caller_code), +index(event_date) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_sip_event_archive_details ( +wday TINYINT(1) UNSIGNED PRIMARY KEY NOT NULL, +start_event_date DATETIME(6), +end_event_date DATETIME(6), +record_count INT(9) UNSIGNED default '0' +) ENGINE=MyISAM; + +CREATE TABLE vicidial_sip_event_recent ( +caller_code VARCHAR(20) default '', +channel VARCHAR(100), +server_ip VARCHAR(15), +uniqueid VARCHAR(20), +invite_date DATETIME(6), +first_100_date DATETIME(6), +first_180_date DATETIME(6), +first_183_date DATETIME(6), +last_100_date DATETIME(6), +last_180_date DATETIME(6), +last_183_date DATETIME(6), +200_date DATETIME(6), +error_date DATETIME(6), +processed ENUM('N','Y','U') default 'N', +index(caller_code), +index(invite_date), +index(processed) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_log_extended_sip ( +call_date DATETIME(6), +caller_code VARCHAR(30) NOT NULL, +invite_to_ring DECIMAL(10,6) DEFAULT '0.000000', +ring_to_final DECIMAL(10,6) DEFAULT '0.000000', +invite_to_final DECIMAL(10,6) DEFAULT '0.000000', +last_event_code SMALLINT(3) default '0', +index(call_date), +index(caller_code) +) ENGINE=MyISAM; + ALTER TABLE vicidial_email_list MODIFY message text character set utf8; @@ -4214,6 +4266,9 @@ CREATE TABLE vicidial_outbound_ivr_log_archive LIKE vicidial_outbound_ivr_log; CREATE TABLE vicidial_log_extended_archive LIKE vicidial_log_extended; CREATE UNIQUE INDEX vlea on vicidial_log_extended_archive (uniqueid,call_date,lead_id); +CREATE TABLE vicidial_log_extended_sip_archive LIKE vicidial_log_extended_sip; +CREATE UNIQUE INDEX vlesa on vicidial_log_extended_sip_archive (caller_code,call_date); + CREATE TABLE vicidial_log_noanswer_archive LIKE vicidial_log_noanswer; CREATE TABLE vicidial_did_agent_log_archive LIKE vicidial_did_agent_log; @@ -4270,6 +4325,21 @@ CREATE UNIQUE INDEX amd_unq_key on vicidial_amd_log_archive(uniqueid, call_date, CREATE TABLE vicidial_sessions_recent_archive LIKE vicidial_sessions_recent; +CREATE TABLE vicidial_sip_event_log_0 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_0 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_1 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_1 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_2 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_2 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_3 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_3 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_4 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_4 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_5 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_5 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_6 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_6 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; + GRANT RELOAD ON *.* TO cron@'%'; GRANT RELOAD ON *.* TO cron@localhost; @@ -4350,4 +4420,4 @@ INSERT INTO vicidial_settings_containers(container_id,container_notes,container_ UPDATE system_settings set vdc_agent_api_active='1'; -UPDATE system_settings SET db_schema_version='1570',db_schema_update_date=NOW(),reload_timestamp=NOW(); +UPDATE system_settings SET db_schema_version='1571',db_schema_update_date=NOW(),reload_timestamp=NOW(); diff --git a/agc_2-X/trunk/extras/sip_logging.patch b/agc_2-X/trunk/extras/sip_logging.patch new file mode 100644 index 00000000..9ad64dc9 --- /dev/null +++ b/agc_2-X/trunk/extras/sip_logging.patch @@ -0,0 +1,50 @@ +--- ../asterisk-13.21.1.stock/channels/chan_sip.c 2018-06-11 17:02:31.000000000 -0400 ++++ channels/chan_sip.c 2019-05-28 22:08:06.304964097 -0400 +@@ -6528,6 +6528,22 @@ + dialog_unref(_data, "dialog ptr dec when SCHED_REPLACE del op succeeded"), + dialog_unref(p, "dialog ptr dec when SCHED_REPLACE add failed"), + dialog_ref(p, "dialog ptr inc when SCHED_REPLACE add succeeded") ); ++ ++ if ( p->owner ) { ++ manager_event(EVENT_FLAG_CALL, "SIPInvite", ++ "Channel: %s\r\n" ++ "Uniqueid: %s\r\n" ++ "SIPCallID: %s\r\n" ++ "CallerIDName: %s\r\n" ++ "ConnectedLineName: %s\r\n", ++ ast_channel_name(p->owner), ++ ast_channel_uniqueid(p->owner), ++ p->callid, ++ ast_channel_caller(p->owner)->id.name.str, ++ ast_channel_connected(p->owner)->id.name.str ++ ); ++ } ++ + sip_pvt_unlock(p); + } + return res; +@@ -24846,6 +24862,24 @@ + ast_channel_hangupcause_set(owner, hangup_sip2cause(resp)); + } + ++ if ( p->owner ) { ++ manager_event(EVENT_FLAG_CALL, "SIPResponse", ++ "Response: %d\r\n" ++ "Channel: %s\r\n" ++ "Uniqueid: %s\r\n" ++ "SIPCallID: %s\r\n" ++ "CallerIDName: %s\r\n" ++ "ConnectedLineName: %s\r\n", ++ resp, ++ ast_channel_name(p->owner), ++ ast_channel_uniqueid(p->owner), ++ p->callid, ++ ast_channel_caller(p->owner)->id.name.str, ++ ast_channel_connected(p->owner)->id.name.str ++ ); ++ } ++ ++ + /* Acknowledge whatever it is destined for */ + if ((resp >= 100) && (resp <= 199)) { + /* NON-INVITE messages do not ack a 1XX response. RFC 3261 section 17.1.2.2 */ diff --git a/agc_2-X/trunk/extras/upgrade_2.14.sql b/agc_2-X/trunk/extras/upgrade_2.14.sql index e7128095..d8e0e4ed 100644 --- a/agc_2-X/trunk/extras/upgrade_2.14.sql +++ b/agc_2-X/trunk/extras/upgrade_2.14.sql @@ -853,3 +853,76 @@ UPDATE system_settings SET db_schema_version='1569',db_schema_update_date=NOW() ALTER TABLE system_settings ADD list_status_modification_confirmation ENUM('1','0') default '0'; UPDATE system_settings SET db_schema_version='1570',db_schema_update_date=NOW() where db_schema_version < 1570; + +ALTER TABLE system_settings ADD sip_event_logging ENUM('0','1','2','3','4','5','6','7') default '0'; + +CREATE TABLE vicidial_sip_event_log ( +sip_event_id INT(9) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL, +caller_code VARCHAR(30) NOT NULL, +channel VARCHAR(100), +server_ip VARCHAR(15), +uniqueid VARCHAR(20), +sip_call_id VARCHAR(256), +event_date DATETIME(6), +event VARCHAR(10), +index(caller_code), +index(event_date) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_sip_event_log_0 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_0 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_1 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_1 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_2 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_2 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_3 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_3 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_4 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_4 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_5 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_5 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; +CREATE TABLE vicidial_sip_event_log_6 LIKE vicidial_sip_event_log; +ALTER TABLE vicidial_sip_event_log_6 MODIFY sip_event_id INT(9) UNSIGNED NOT NULL; + +CREATE TABLE vicidial_sip_event_archive_details ( +wday TINYINT(1) UNSIGNED PRIMARY KEY NOT NULL, +start_event_date DATETIME(6), +end_event_date DATETIME(6), +record_count INT(9) UNSIGNED default '0' +) ENGINE=MyISAM; + +CREATE TABLE vicidial_sip_event_recent ( +caller_code VARCHAR(20) default '', +channel VARCHAR(100), +server_ip VARCHAR(15), +uniqueid VARCHAR(20), +invite_date DATETIME(6), +first_100_date DATETIME(6), +first_180_date DATETIME(6), +first_183_date DATETIME(6), +last_100_date DATETIME(6), +last_180_date DATETIME(6), +last_183_date DATETIME(6), +200_date DATETIME(6), +error_date DATETIME(6), +processed ENUM('N','Y','U') default 'N', +index(caller_code), +index(invite_date), +index(processed) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_log_extended_sip ( +call_date DATETIME(6), +caller_code VARCHAR(30) NOT NULL, +invite_to_ring DECIMAL(10,6) DEFAULT '0.000000', +ring_to_final DECIMAL(10,6) DEFAULT '0.000000', +invite_to_final DECIMAL(10,6) DEFAULT '0.000000', +last_event_code SMALLINT(3) default '0', +index(call_date), +index(caller_code) +) ENGINE=MyISAM; + +CREATE TABLE vicidial_log_extended_sip_archive LIKE vicidial_log_extended_sip; +CREATE UNIQUE INDEX vlesa on vicidial_log_extended_sip_archive (caller_code,call_date); + +UPDATE system_settings SET db_schema_version='1571',db_schema_update_date=NOW() where db_schema_version < 1571; diff --git a/agc_2-X/trunk/install.pl b/agc_2-X/trunk/install.pl index 93a839d2..94c7fa76 100644 --- a/agc_2-X/trunk/install.pl +++ b/agc_2-X/trunk/install.pl @@ -2,7 +2,7 @@ # install.pl version 2.14 # -# Copyright (C) 2017 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2019 Matt Florell LICENSE: AGPLv2 # # CHANGES @@ -43,6 +43,7 @@ # 151212-0840 - Added chat_customer web directory, removed static language build actions # 160101-0907 - Changed ip_relay code to look for installed package # 170915-1458 - Added Asterisk 13 compability pieces +# 190530-1511 - Added 'S' keepalive option # ############################################ @@ -206,6 +207,7 @@ if (length($ARGV[0])>1) print " 8 - ip_relay (used for blind agent monitoring)\n"; print " 9 - Timeclock auto-logout\n"; print " E - Email processor, (If multi-server system, this must only be on one server)\n"; + print " S - SIP Logger (Patched Asterisk 13 required)\n"; print " [--asterisk_version] = set the asterisk version you want to install for\n"; print " [--copy_sample_conf_files] = copies the sample conf files to /etc/asterisk/\n"; print " [--web-languages] = copy language translations (WARNING! may not work on trunk installs)\n"; @@ -1820,6 +1822,7 @@ else print " 8 - ip_relay (used for blind agent monitoring)\n"; print " 9 - Timeclock auto logout\n"; print " E - Email processor, (If multi-server system, this must only be on one server)\n"; + print " S - SIP Logger (Patched Asterisk 13 required)\n"; print "Enter active keepalives or press enter for default: [$VARactive_keepalives] "; $PROMPTactive_keepalives = ; chomp($PROMPTactive_keepalives); @@ -2425,6 +2428,7 @@ print conf "# 7 - AST_VDauto_dial_FILL (only for multi-server, this must only b print conf "# 8 - ip_relay (used for blind agent monitoring)\n"; print conf "# 9 - Timeclock auto logout, (If multi-server system, this must only be on one server)\n"; print conf "# E - Email processor, (If multi-server system, this must only be on one server)\n"; +print conf "# S - SIP Logger (Patched Asterisk 13 required)\n"; print conf "VARactive_keepalives => $VARactive_keepalives\n"; print conf "\n"; print conf "# Asterisk version VICIDIAL is installed for\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 56aa4d87..aafd8a43 100644 --- a/agc_2-X/trunk/www/agc/vdc_db_query.php +++ b/agc_2-X/trunk/www/agc/vdc_db_query.php @@ -473,10 +473,11 @@ # 190406-1614 - Added agent next_dial_my_callbacks override # 190515-1556 - Fixed scheduled callback email alert bug # 190524-1142 - Added gmt_offset population to new manual dialed leads +# 190531-1045 - Added sip_event_logging # -$version = '2.14-367'; -$build = '190524-1142'; +$version = '2.14-368'; +$build = '190531-1045'; $php_script = 'vdc_db_query.php'; $mel=1; # Mysql Error Log enabled = 1 $mysql_log_count=793; @@ -948,7 +949,7 @@ $sip_hangup_cause_dictionary = array( ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,qc_features_active,allow_emails,callback_time_24hour,enable_languages,language_method,agent_debug_logging,default_language,active_modules,allow_chats,default_phone_code,user_new_lead_limit FROM system_settings;"; +$stmt = "SELECT use_non_latin,timeclock_end_of_day,agentonly_callback_campaign_lock,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,qc_features_active,allow_emails,callback_time_24hour,enable_languages,language_method,agent_debug_logging,default_language,active_modules,allow_chats,default_phone_code,user_new_lead_limit,sip_event_logging FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00001',$user,$server_ip,$session_name,$one_mysql_log);} if ($DB) {echo "$stmt\n";} @@ -975,6 +976,7 @@ if ($qm_conf_ct > 0) $allow_chats = $row[16]; $default_phone_code = $row[17]; $SSuser_new_lead_limit = $row[18]; + $SSsip_event_logging = $row[19]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -6715,6 +6717,71 @@ if ($ACTION == 'manDiaLlookCaLL') if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00742',$user,$server_ip,$session_name,$one_mysql_log);} } + ##### BEGIN SIP event logging, if enabled in the system ##### + if ($SSsip_event_logging > 0) + { + ##### insert log into vicidial_log_extended for manual VICIDiaL call + $stmt="UPDATE vicidial_sip_event_recent set processed='U' where caller_code='$MDnextCID' LIMIT 1;;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysqli_affected_rows($link); + + if ($affected_rowsX > 0) + { + $stmt = "SELECT invite_date,first_180_date,first_183_date,200_date,(200_date - invite_date) as dial,(first_180_date - invite_date) as prog,(first_180_date - invite_date) as pdd from vicidial_sip_event_recent where caller_code='$MDnextCID' LIMIT 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $VSER_ct = mysqli_num_rows($rslt); + if ($VSER_ct > 0) + { + $row=mysqli_fetch_row($rslt); + $invite_date = $row[0]; + $first_180_date = $row[1]; + $first_183_date = $row[2]; + $sip200_date = $row[3]; + $dial_time = $row[4]; + $time_to_progress = $row[5]; + $time_to_ring = $row[6]; + + if ( ($time_to_progress > 0) && ($time_to_progress != 'NULL') ) + { + $invite_to_ring = $time_to_progress; + $ring_to_final = ($dial_time - $invite_to_ring); + } + else + { + if ( ($time_to_ring > 0) && ($time_to_ring != 'NULL') ) + { + $invite_to_ring = $time_to_ring; + $ring_to_final = ($dial_time - $invite_to_ring); + } + else + { + $invite_to_ring = 0; + $ring_to_final = 0; + } + } + + # insert a record into the vicidial_log_extended_sip table for this call + $stmt = "INSERT INTO vicidial_log_extended_sip SET call_date='$invite_date', caller_code='$MDnextCID', invite_to_ring='$invite_to_ring', ring_to_final='$ring_to_final', invite_to_final='$dial_time', last_event_code='200' LIMIT 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysqli_affected_rows($link); + + # flag the vicidial_sip_event_recent record as processed + $stmt = "UPDATE vicidial_sip_event_recent set processed='Y' where caller_code='$MDnextCID' LIMIT 1;"; + if ($DB) {echo "$stmt\n";} + $rslt=mysql_to_mysqli($stmt, $link); + if ($mel > 0) {mysql_error_logging($NOW_TIME,$link,$mel,$stmt,'00XXX',$user,$server_ip,$session_name,$one_mysql_log);} + $affected_rowsX = mysqli_affected_rows($link); + } + } + } + ##### END SIP event logging, if enabled in the system ##### + echo "$call_output"; $stage .= " $uniqueid $channel"; diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index fa3b61e1..1012e06d 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -2429,6 +2429,8 @@ if (isset($_GET["user_admin_redirect"])) {$user_admin_redirect=$_GET["user_adm elseif (isset($_POST["user_admin_redirect"])) {$user_admin_redirect=$_POST["user_admin_redirect"];} if (isset($_GET["user_admin_redirect_url"])) {$user_admin_redirect_url=$_GET["user_admin_redirect_url"];} elseif (isset($_POST["user_admin_redirect_url"])) {$user_admin_redirect_url=$_POST["user_admin_redirect_url"];} +if (isset($_GET["sip_event_logging"])) {$sip_event_logging=$_GET["sip_event_logging"];} + elseif (isset($_POST["sip_event_logging"])) {$sip_event_logging=$_POST["sip_event_logging"];} if (isset($script_id)) {$script_id= strtoupper($script_id);} @@ -2443,7 +2445,7 @@ if (strlen($dial_status) > 0) ############################################# ##### START SYSTEM_SETTINGS LOOKUP ##### -$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,allow_emails,level_8_disable_add,pass_key,pass_hash_enabled,disable_auto_dial,country_code_list_stats,frozen_server_call_clear,active_modules,allow_chats,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,default_language,user_hide_realtime_enabled,log_recording_access,alt_ivr_logging,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way,agent_soundboards,web_loader_phone_length,agent_script,enable_auto_reports,enable_pause_code_limits,enable_drop_lists,allow_ip_lists,system_ip_blacklist,hide_inactive_lists,allow_manage_active_lists,expired_lists_inactive,did_system_filter,enable_gdpr_download_deletion,mute_recordings,user_admin_redirect,list_status_modification_confirmation FROM system_settings;"; +$stmt = "SELECT use_non_latin,enable_queuemetrics_logging,enable_vtiger_integration,qc_features_active,outbound_autodial_active,sounds_central_control_active,enable_second_webform,user_territories_active,custom_fields_enabled,admin_web_directory,webphone_url,first_login_trigger,hosted_settings,default_phone_registration_password,default_phone_login_password,default_server_password,test_campaign_calls,active_voicemail_server,voicemail_timezones,default_voicemail_timezone,default_local_gmt,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,allow_emails,level_8_disable_add,pass_key,pass_hash_enabled,disable_auto_dial,country_code_list_stats,frozen_server_call_clear,active_modules,allow_chats,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,default_language,user_hide_realtime_enabled,log_recording_access,alt_ivr_logging,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way,agent_soundboards,web_loader_phone_length,agent_script,enable_auto_reports,enable_pause_code_limits,enable_drop_lists,allow_ip_lists,system_ip_blacklist,hide_inactive_lists,allow_manage_active_lists,expired_lists_inactive,did_system_filter,enable_gdpr_download_deletion,mute_recordings,user_admin_redirect,list_status_modification_confirmation,sip_event_logging FROM system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); if ($DB) {echo "$stmt\n";} $qm_conf_ct = mysqli_num_rows($rslt); @@ -2527,7 +2529,8 @@ if ($qm_conf_ct > 0) $SSenable_gdpr_download_deletion = $row[74]; $SSmute_recordings = $row[75]; $SSuser_admin_redirect = $row[76]; - $SSlist_status_modification_confirmation = $row[77]; + $SSlist_status_modification_confirmation = $row[77]; + $SSsip_event_logging = $row[78]; } ##### END SETTINGS LOOKUP ##### ########################################### @@ -2860,6 +2863,8 @@ if ($non_latin < 1) $max_hopper_calls_hour = preg_replace('/[^0-9]/','',$max_hopper_calls_hour); $agent_logout_link = preg_replace('/[^0-9]/','',$agent_logout_link); $user_admin_redirect = preg_replace('/[^0-9]/','',$user_admin_redirect); + $list_status_modification_confirmation = preg_replace('/[^0-9]/','',$list_status_modification_confirmation); + $sip_event_logging = preg_replace('/[^0-9]/','',$sip_event_logging); $user_new_lead_limit = preg_replace('/[^-0-9]/','',$user_new_lead_limit); $drop_call_seconds = preg_replace('/[^-0-9]/','',$drop_call_seconds); @@ -4499,12 +4504,13 @@ else # 190406-1437 - Added user override option for next_dial_my_callbacks # 190414-0924 - Added user_admin_redirect system setting and user option # 190530-1014 - Added list_status_modification_confirmation feature +# 190530-1715 - Added sip_event_logging system setting # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.14-709a'; -$build = '190530-1014'; +$admin_version = '2.14-710a'; +$build = '190530-1715'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -17646,7 +17652,7 @@ if ($ADD==411111111111111) } } - $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',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysqli_real_escape_string($link, $webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db'$custom_reports_slave_SQL,webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append',test_campaign_calls='$test_campaign_calls',agents_calls_reset='$agents_calls_reset',default_voicemail_timezone='$default_voicemail_timezone',default_local_gmt='$default_local_gmt',noanswer_log='$noanswer_log',alt_log_server_ip='$alt_log_server_ip',alt_log_dbname='$alt_log_dbname',alt_log_login='$alt_log_login',alt_log_pass='$alt_log_pass',tables_use_alt_log_db='$tables_use_alt_log_db',did_agent_log='$did_agent_log',campaign_cid_areacodes_enabled='$campaign_cid_areacodes_enabled',pllb_grouping_limit='$pllb_grouping_limit',did_ra_extensions_enabled='$did_ra_extensions_enabled',expanded_list_stats='$expanded_list_stats',contacts_enabled='$contacts_enabled',call_menu_qualify_enabled='$call_menu_qualify_enabled',admin_list_counts='$admin_list_counts',allow_voicemail_greeting='$allow_voicemail_greeting',queuemetrics_socket='$queuemetrics_socket',queuemetrics_socket_url='$queuemetrics_socket_url',enhanced_disconnect_logging='$enhanced_disconnect_logging',allow_emails='$allow_emails',level_8_disable_add='$level_8_disable_add',queuemetrics_record_hold='$queuemetrics_record_hold',country_code_list_stats='$country_code_list_stats',queuemetrics_pause_type='$queuemetrics_pause_type',frozen_server_call_clear='$frozen_server_call_clear',callback_time_24hour='$callback_time_24hour',enable_languages='$enable_languages',language_method='$language_method',meetme_enter_login_filename='$meetme_enter_login_filename',meetme_enter_leave3way_filename='$meetme_enter_leave3way_filename',enable_did_entry_list_id='$enable_did_entry_list_id',enable_third_webform='$enable_third_webform',allow_chats='$allow_chats',chat_url='$chat_url',chat_timeout='$chat_timeout',agent_debug_logging='$agent_debug_logging',default_language='$default_language',agent_whisper_enabled='$agent_whisper_enabled',user_hide_realtime_enabled='$user_hide_realtime_enabled',usacan_phone_dialcode_fix='$usacan_phone_dialcode_fix',cache_carrier_stats_realtime='$cache_carrier_stats_realtime',log_recording_access='$log_recording_access',report_default_format='$report_default_format',alt_ivr_logging='$alt_ivr_logging',default_phone_code='$default_phone_code',admin_row_click='$admin_row_click',admin_screen_colors='$admin_screen_colors',ofcom_uk_drop_calc='$ofcom_uk_drop_calc',agent_screen_colors='$agent_screen_colors',script_remove_js='$script_remove_js',manual_auto_next='$manual_auto_next',user_new_lead_limit='$user_new_lead_limit',agent_xfer_park_3way='$agent_xfer_park_3way',agent_soundboards='$agent_soundboards',web_loader_phone_length='$web_loader_phone_length',agent_script='$agent_script',agent_chat_screen_colors='$agent_chat_screen_colors',enable_auto_reports='$enable_auto_reports',enable_pause_code_limits='$enable_pause_code_limits',enable_drop_lists='$enable_drop_lists',allow_ip_lists='$allow_ip_lists',system_ip_blacklist='$system_ip_blacklist',agent_push_events='$agent_push_events',agent_push_url='$agent_push_url',hide_inactive_lists='$hide_inactive_lists',allow_manage_active_lists='$allow_manage_active_lists',expired_lists_inactive='$expired_lists_inactive',did_system_filter='$did_system_filter',anyone_callback_inactive_lists='$anyone_callback_inactive_lists',enable_gdpr_download_deletion='$enable_gdpr_download_deletion',source_id_display='$source_id_display',agent_logout_link='$agent_logout_link',manual_dial_validation='$manual_dial_validation',mute_recordings='$mute_recordings',user_admin_redirect='$user_admin_redirect',list_status_modification_confirmation='$list_status_modification_confirmation'$custom_dialplanSQL;"; + $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',enable_tts_integration='$enable_tts_integration',agentonly_callback_campaign_lock='$agentonly_callback_campaign_lock',sounds_central_control_active='$sounds_central_control_active',sounds_web_server='$sounds_web_server',sounds_web_directory='$sounds_web_directory',active_voicemail_server='$active_voicemail_server',auto_dial_limit='$auto_dial_limit',user_territories_active='$user_territories_active',allow_custom_dialplan='$allow_custom_dialplan',enable_second_webform='$enable_second_webform',default_webphone='$default_webphone',default_external_server_ip='$default_external_server_ip',webphone_url='" . mysqli_real_escape_string($link, $webphone_url) . "',enable_agc_dispo_log='$enable_agc_dispo_log',queuemetrics_loginout='$queuemetrics_loginout',callcard_enabled='$callcard_enabled',queuemetrics_callstatus='$queuemetrics_callstatus',default_codecs='$default_codecs',admin_web_directory='$admin_web_directory',label_title='$label_title',label_first_name='$label_first_name',label_middle_initial='$label_middle_initial',label_last_name='$label_last_name',label_address1='$label_address1',label_address2='$label_address2',label_address3='$label_address3',label_city='$label_city',label_state='$label_state',label_province='$label_province',label_postal_code='$label_postal_code',label_vendor_lead_code='$label_vendor_lead_code',label_gender='$label_gender',label_phone_number='$label_phone_number',label_phone_code='$label_phone_code',label_alt_phone='$label_alt_phone',label_security_phrase='$label_security_phrase',label_email='$label_email',label_comments='$label_comments',custom_fields_enabled='$custom_fields_enabled',slave_db_server='$slave_db_server',reports_use_slave_db='$reports_use_slave_db'$custom_reports_slave_SQL,webphone_systemkey='$webphone_systemkey',first_login_trigger='$first_login_trigger',default_phone_registration_password='$default_phone_registration_password',default_phone_login_password='$default_phone_login_password',default_server_password='$default_server_password',admin_modify_refresh='$admin_modify_refresh',nocache_admin='$nocache_admin',generate_cross_server_exten='$generate_cross_server_exten',queuemetrics_addmember_enabled='$queuemetrics_addmember_enabled',queuemetrics_dispo_pause='$queuemetrics_dispo_pause',label_hide_field_logs='$label_hide_field_logs',queuemetrics_pe_phone_append='$queuemetrics_pe_phone_append',test_campaign_calls='$test_campaign_calls',agents_calls_reset='$agents_calls_reset',default_voicemail_timezone='$default_voicemail_timezone',default_local_gmt='$default_local_gmt',noanswer_log='$noanswer_log',alt_log_server_ip='$alt_log_server_ip',alt_log_dbname='$alt_log_dbname',alt_log_login='$alt_log_login',alt_log_pass='$alt_log_pass',tables_use_alt_log_db='$tables_use_alt_log_db',did_agent_log='$did_agent_log',campaign_cid_areacodes_enabled='$campaign_cid_areacodes_enabled',pllb_grouping_limit='$pllb_grouping_limit',did_ra_extensions_enabled='$did_ra_extensions_enabled',expanded_list_stats='$expanded_list_stats',contacts_enabled='$contacts_enabled',call_menu_qualify_enabled='$call_menu_qualify_enabled',admin_list_counts='$admin_list_counts',allow_voicemail_greeting='$allow_voicemail_greeting',queuemetrics_socket='$queuemetrics_socket',queuemetrics_socket_url='$queuemetrics_socket_url',enhanced_disconnect_logging='$enhanced_disconnect_logging',allow_emails='$allow_emails',level_8_disable_add='$level_8_disable_add',queuemetrics_record_hold='$queuemetrics_record_hold',country_code_list_stats='$country_code_list_stats',queuemetrics_pause_type='$queuemetrics_pause_type',frozen_server_call_clear='$frozen_server_call_clear',callback_time_24hour='$callback_time_24hour',enable_languages='$enable_languages',language_method='$language_method',meetme_enter_login_filename='$meetme_enter_login_filename',meetme_enter_leave3way_filename='$meetme_enter_leave3way_filename',enable_did_entry_list_id='$enable_did_entry_list_id',enable_third_webform='$enable_third_webform',allow_chats='$allow_chats',chat_url='$chat_url',chat_timeout='$chat_timeout',agent_debug_logging='$agent_debug_logging',default_language='$default_language',agent_whisper_enabled='$agent_whisper_enabled',user_hide_realtime_enabled='$user_hide_realtime_enabled',usacan_phone_dialcode_fix='$usacan_phone_dialcode_fix',cache_carrier_stats_realtime='$cache_carrier_stats_realtime',log_recording_access='$log_recording_access',report_default_format='$report_default_format',alt_ivr_logging='$alt_ivr_logging',default_phone_code='$default_phone_code',admin_row_click='$admin_row_click',admin_screen_colors='$admin_screen_colors',ofcom_uk_drop_calc='$ofcom_uk_drop_calc',agent_screen_colors='$agent_screen_colors',script_remove_js='$script_remove_js',manual_auto_next='$manual_auto_next',user_new_lead_limit='$user_new_lead_limit',agent_xfer_park_3way='$agent_xfer_park_3way',agent_soundboards='$agent_soundboards',web_loader_phone_length='$web_loader_phone_length',agent_script='$agent_script',agent_chat_screen_colors='$agent_chat_screen_colors',enable_auto_reports='$enable_auto_reports',enable_pause_code_limits='$enable_pause_code_limits',enable_drop_lists='$enable_drop_lists',allow_ip_lists='$allow_ip_lists',system_ip_blacklist='$system_ip_blacklist',agent_push_events='$agent_push_events',agent_push_url='$agent_push_url',hide_inactive_lists='$hide_inactive_lists',allow_manage_active_lists='$allow_manage_active_lists',expired_lists_inactive='$expired_lists_inactive',did_system_filter='$did_system_filter',anyone_callback_inactive_lists='$anyone_callback_inactive_lists',enable_gdpr_download_deletion='$enable_gdpr_download_deletion',source_id_display='$source_id_display',agent_logout_link='$agent_logout_link',manual_dial_validation='$manual_dial_validation',mute_recordings='$mute_recordings',user_admin_redirect='$user_admin_redirect',list_status_modification_confirmation='$list_status_modification_confirmation',sip_event_logging='$sip_event_logging'$custom_dialplanSQL;"; $rslt=mysql_to_mysqli($stmt, $link); if ( ($meetme_enter_login_filename != $SSmeetme_enter_login_filename) or ($meetme_enter_leave3way_filename != $SSmeetme_enter_leave3way_filename) ) @@ -36669,7 +36675,7 @@ if ($ADD==311111111111111) $ALLagent_count = $rowx[2]; } - $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,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging,allow_emails,level_8_disable_add,pass_hash_enabled,pass_key,pass_cost,disable_auto_dial,queuemetrics_record_hold,country_code_list_stats,reload_timestamp,queuemetrics_pause_type,frozen_server_call_clear,callback_time_24hour,allow_chats,chat_url,chat_timeout,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,agent_debug_logging,default_language,agent_whisper_enabled,user_hide_realtime_enabled,usacan_phone_dialcode_fix,cache_carrier_stats_realtime,oldest_logs_date,log_recording_access,report_default_format,alt_ivr_logging,default_phone_code,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way,rec_prompt_count,agent_soundboards,web_loader_phone_length,agent_script,agent_chat_screen_colors,enable_auto_reports,enable_pause_code_limits,enable_drop_lists,allow_ip_lists,system_ip_blacklist,agent_push_events,agent_push_url,hide_inactive_lists,allow_manage_active_lists,expired_lists_inactive,did_system_filter,anyone_callback_inactive_lists,enable_gdpr_download_deletion,source_id_display,agent_logout_link,manual_dial_validation,mute_recordings,user_admin_redirect,list_status_modification_confirmation 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,enable_tts_integration,agentonly_callback_campaign_lock,sounds_central_control_active,sounds_web_server,sounds_web_directory,active_voicemail_server,auto_dial_limit,user_territories_active,allow_custom_dialplan,db_schema_update_date,enable_second_webform,default_webphone,default_external_server_ip,webphone_url,enable_agc_dispo_log,custom_dialplan_entry,queuemetrics_loginout,callcard_enabled,queuemetrics_callstatus,default_codecs,admin_web_directory,label_title,label_first_name,label_middle_initial,label_last_name,label_address1,label_address2,label_address3,label_city,label_state,label_province,label_postal_code,label_vendor_lead_code,label_gender,label_phone_number,label_phone_code,label_alt_phone,label_security_phrase,label_email,label_comments,custom_fields_enabled,slave_db_server,reports_use_slave_db,webphone_systemkey,first_login_trigger,default_phone_registration_password,default_phone_login_password,default_server_password,admin_modify_refresh,nocache_admin,generate_cross_server_exten,queuemetrics_addmember_enabled,queuemetrics_dispo_pause,label_hide_field_logs,queuemetrics_pe_phone_append,test_campaign_calls,agents_calls_reset,default_voicemail_timezone,default_local_gmt,noanswer_log,alt_log_server_ip,alt_log_dbname,alt_log_login,alt_log_pass,tables_use_alt_log_db,did_agent_log,campaign_cid_areacodes_enabled,pllb_grouping_limit,did_ra_extensions_enabled,expanded_list_stats,contacts_enabled,call_menu_qualify_enabled,admin_list_counts,allow_voicemail_greeting,svn_revision,queuemetrics_socket,queuemetrics_socket_url,enhanced_disconnect_logging,allow_emails,level_8_disable_add,pass_hash_enabled,pass_key,pass_cost,disable_auto_dial,queuemetrics_record_hold,country_code_list_stats,reload_timestamp,queuemetrics_pause_type,frozen_server_call_clear,callback_time_24hour,allow_chats,chat_url,chat_timeout,enable_languages,language_method,meetme_enter_login_filename,meetme_enter_leave3way_filename,enable_did_entry_list_id,enable_third_webform,agent_debug_logging,default_language,agent_whisper_enabled,user_hide_realtime_enabled,usacan_phone_dialcode_fix,cache_carrier_stats_realtime,oldest_logs_date,log_recording_access,report_default_format,alt_ivr_logging,default_phone_code,admin_row_click,admin_screen_colors,ofcom_uk_drop_calc,agent_screen_colors,script_remove_js,manual_auto_next,user_new_lead_limit,agent_xfer_park_3way,rec_prompt_count,agent_soundboards,web_loader_phone_length,agent_script,agent_chat_screen_colors,enable_auto_reports,enable_pause_code_limits,enable_drop_lists,allow_ip_lists,system_ip_blacklist,agent_push_events,agent_push_url,hide_inactive_lists,allow_manage_active_lists,expired_lists_inactive,did_system_filter,anyone_callback_inactive_lists,enable_gdpr_download_deletion,source_id_display,agent_logout_link,manual_dial_validation,mute_recordings,user_admin_redirect,list_status_modification_confirmation,sip_event_logging from system_settings;"; $rslt=mysql_to_mysqli($stmt, $link); $row=mysqli_fetch_row($rslt); $version = $row[0]; @@ -36848,6 +36854,7 @@ if ($ADD==311111111111111) $mute_recordings = $row[173]; $user_admin_redirect = $row[174]; $list_status_modification_confirmation = $row[175]; + $sip_event_logging = $row[176]; if ($pass_hash_enabled > 0) {$pass_hash_enabled = 'ENABLED';} else {$pass_hash_enabled = 'DISABLED';} @@ -37129,6 +37136,8 @@ if ($ADD==311111111111111) echo ""._QXZ("Enhanced Disconnect Logging").": $NWB#settings-enhanced_disconnect_logging$NWE\n"; + echo ""._QXZ("SIP Event Logging").": $NWB#settings-sip_event_logging$NWE\n"; + echo ""._QXZ("Cached Realtime Carrier Stats").": $NWB#settings-cache_carrier_stats_realtime$NWE\n"; echo ""._QXZ("Enable CID Groups and Campaign Areacode CID").": $NWB#settings-campaign_cid_areacodes_enabled$NWE\n"; diff --git a/agc_2-X/trunk/www/vicidial/help_documentation.txt b/agc_2-X/trunk/www/vicidial/help_documentation.txt index b5001dd6..ccae9290 100644 --- a/agc_2-X/trunk/www/vicidial/help_documentation.txt +++ b/agc_2-X/trunk/www/vicidial/help_documentation.txt @@ -1,4 +1,4 @@ -# version: 20190528114301 +# version: 20190530194101 users-user User ID This field is where you put the users ID number, can be up to 8 digits in length, Must be at least 2 characters in length. users-pass Password This field is where you put the users password. Must be at least 2 characters in length. A medium strength user password will be at least 10 characters in length, and a strong user password will be at least 20 characters in length and have letters as well as at least one number. It is recommended that you use a longer password if possible, stringing together several unrelated words with no spaces, and a number somewhere in the string. The maximum size of a password is 100 characters. users-force_change_password Force Change Password If this option is set to Y then the user will be prompted to change their password the next time they log in to the administration webpage. Default is N. @@ -1022,6 +1022,7 @@ settings-enable_drop_lists Enable Drop Lists This setting if enabled will m settings-source_id_display Admin Lead Source ID Display This setting will make the Source ID lead field show up in the Admin Modify Lead screen. Default is 0 for disabled. settings-agent_debug_logging Agent Screen Debug Logging This setting if enabled will log almost all agent screen mouse clicks and AJAX processes triggered by the agent screen. To enable for all agents, set this option to 1. To enable only for one agent on the system, set this option to the user that you want to log. Warning, this feature can log hundreds of entries per phone call, so use with caution. These agent debug records are deleted after 7 days. Default is 0 for disabled. settings-enhanced_disconnect_logging Enhanced Disconnect Logging This setting enables logging of calls that get a CONGESTION signal with a cause code of 1, 19, 21, 34 or 38. We usually do not recommend enabling this in the USA. Default is 0 for disabled. +settings-sip_event_logging SIP Event Logging This setting will enable logging of SIP events on outbound phone calls for servers that are running patched versions of Asterisk 13 or higher. Default is 0 for disabled. settings-cache_carrier_stats_realtime Cached Realtime Carrier Stats This setting if enabled will change the real-time report from gathering the carrier log stats every time it is refreshed on every screen it is running on, to a cached set of carrier log stats that are refreshed once per minute. Default is 0 for disabled. settings-campaign_cid_areacodes_enabled Enable CID Groups and Campaign Areacode CID This setting enables the ability to set specific outbound callerid numbers to be used per areacode for a campaign, as well as CID Groups which allows both per areacode and per state options for groups of CallerID numbers for one or multiple campaigns. Default is 1 for enabled. settings-did_ra_extensions_enabled Enable Remote Agent Extension Overrides This setting enables DIDs to have extension overrides for remote agent routed calls through in-groups. Default is 0 for disabled.