Added Internal Process Logs generation and admin display
git-svn-id: svn://192.168.202.10@3994 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
# Based on perl scripts in ViciDial from Matt Florell and post:
|
||||
# http://www.vicidial.org/VICIDIALforum/viewtopic.php?p=22506&sid=ca5347cffa6f6382f56ce3db9fb3d068#22506
|
||||
#
|
||||
# Copyright (C) 2025 I. Taushanov, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 I. Taushanov, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 90615-1701 - First version
|
||||
@@ -77,6 +77,7 @@
|
||||
# 251011-2048 - Added archiving of recording_live_log table
|
||||
# 251024-1518 - Added --vicidial-dial-log-only flag
|
||||
# 260111-2138 - Added --agent-log-only flag
|
||||
# 260516-2149 - Added internal logging
|
||||
#
|
||||
|
||||
$CALC_TEST=0;
|
||||
@@ -91,6 +92,7 @@ $api_archive_only=0;
|
||||
$url_log_only=0;
|
||||
$url_log_archive=0;
|
||||
$agent_log_only=0;
|
||||
$script_name = 'ADMIN_archive_log_tables.pl';
|
||||
|
||||
|
||||
### begin parsing run-time options ###
|
||||
@@ -625,6 +627,8 @@ 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;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; &internal_logger;
|
||||
|
||||
#############################################
|
||||
##### Gather system_settings #####
|
||||
$stmtA = "SELECT sip_event_logging FROM system_settings;";
|
||||
@@ -4480,4 +4484,17 @@ $secZ = ($secY - $secX);
|
||||
$secZm = ($secZ /60);
|
||||
if (!$Q) {print "\nscript execution time in seconds: $secZ minutes: $secZm\n";}
|
||||
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='finished', stage='Run seconds: $secZ' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
|
||||
exit;
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
@@ -182,9 +182,10 @@
|
||||
# 260327-0846 - Added check of empty phone dialplan extensions when building conf files
|
||||
# 260402-1440 - Added reset of vicidial_max_inbound_cache table entries
|
||||
# 260515-1610 - Changed multi-listen-process kill section to only run if listen process is supposed to run on this server
|
||||
# 260515-2121 - Added truncating of vicidial_internal_log entries after 7 days, updating of some records
|
||||
#
|
||||
|
||||
$build = '260515-1610';
|
||||
$build = '260515-2121';
|
||||
|
||||
$DB=0; # Debug flag
|
||||
$teodDB=0; # flag to log Timeclock End of Day processes to log file
|
||||
@@ -801,6 +802,14 @@ else
|
||||
$i++;
|
||||
}
|
||||
|
||||
# if $runningFastAGI_log running, update internal process log
|
||||
if ( ($runningFastAGI_log > 0) && ($reset_test =~ /0$|5$/) )
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage=CONCAT((UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(db_time)),' seconds runtime') WHERE process='FastAGI_log.pl' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -866,8 +875,6 @@ else
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##### Third, double-check that non-running scripts are not running #####
|
||||
@psline=@MT;
|
||||
@psoutput=@MT;
|
||||
@@ -2401,7 +2408,25 @@ if ($timeclock_end_of_day_NOW > 0)
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
|
||||
$sthA->finish();
|
||||
##### END vicidial_dtmf_log end of day process removing records older than 7 days #####
|
||||
##### END vicidial_dtmf_log end of day process removing records older than 24 hours #####
|
||||
|
||||
|
||||
##### BEGIN vicidial_internal_log end of day process removing records older than 7 days #####
|
||||
$stmtA = "DELETE from vicidial_internal_log where up_time < \"$SDSQLdate\";";
|
||||
if($DBX){print STDERR "\n|$stmtA|\n";}
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "\n|$affected_rows vicidial_internal_log records older than 7 days purged|\n";}
|
||||
if ($teodDB) {$event_string = "vicidial_internal_log records older than 7 days purged: |$stmtA|$affected_rows|"; &teod_logger;}
|
||||
|
||||
$stmtA = "optimize table vicidial_internal_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;
|
||||
@aryA = $sthA->fetchrow_array;
|
||||
if ($DB) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";}
|
||||
$sthA->finish();
|
||||
##### END vicidial_internal_log end of day process removing records older than 7 days #####
|
||||
|
||||
|
||||
##### BEGIN vicidial_lead_messages end of day process removing records older than 1 day #####
|
||||
@@ -5894,6 +5919,11 @@ if ($active_asterisk_server =~ /Y/)
|
||||
if ($DBX) {print "Restart asterisk debug 1: |$Iaffected_rows|$stmtA|\n";}
|
||||
|
||||
`screen -XS asterisk eval 'stuff "/usr/sbin/asterisk -vvvvgcT\015"'`;
|
||||
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), action='start', stage='restarted', process='asterisk auto-restart', server_ip='$server_ip';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
elsif ($uptime_seconds>300)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# adjusts the auto_dial_level for vicidial adaptive-predictive campaigns.
|
||||
# gather call stats for campaigns and in-groups
|
||||
#
|
||||
# Copyright (C) 2025 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGELOG
|
||||
# 60823-1302 - First build from AST_VDhopper.pl
|
||||
@@ -64,9 +64,11 @@
|
||||
# 250131-1624 - Modifications to fix cached hour counts for realtime report
|
||||
# 250218-1613 - Modified master loop to use microseconds instead of a counter to execute drop/dial level/shared dialing functions
|
||||
# 251205-0949 - Added adaptive_percentmax_percentage option and ADAPT_PERCENTMAX dial_method, fix for dropped cached counts
|
||||
# 260515-1938 - Added internal logging
|
||||
#
|
||||
|
||||
$build='251205-0949';
|
||||
$build='260515-1938';
|
||||
$script_name = 'AST_VDadapt.pl';
|
||||
# constants
|
||||
$DB=0; # Debug flag, set to 0 for no debug messages, On an active system this will generate lots of lines of output per minute
|
||||
$US='__';
|
||||
@@ -320,6 +322,8 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
|
||||
$dbhB = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER '.$build; &internal_logger;
|
||||
|
||||
if ($DBX) {print "CONNECTED TO DATABASE: $VARDB_server|$VARDB_database\n";}
|
||||
|
||||
##### gather relevent system settings
|
||||
@@ -434,6 +438,7 @@ if ($run_check > 0)
|
||||
}
|
||||
|
||||
$master_loop=0;
|
||||
$iLog_ct=0;
|
||||
|
||||
### Start master loop ###
|
||||
while ($master_loop < $CLIloops)
|
||||
@@ -474,7 +479,7 @@ while ($master_loop < $CLIloops)
|
||||
if ($min < 10) {$min = "0$min";}
|
||||
if ($sec < 10) {$sec = "0$sec";}
|
||||
|
||||
if ($DBXXX) {print "TIME DEBUG: $master_loop $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";}
|
||||
if ($DBXXX) {print "TIME DEBUG: $master_loop|$iLog_ct $LOCAL_GMT_OFF_STD|$LOCAL_GMT_OFF|$isdst| GMT: $hour:$min\n";}
|
||||
|
||||
if (!$prev_iteration_ms) {$prev_iteration_ms=time();}
|
||||
|
||||
@@ -2487,6 +2492,15 @@ while ($master_loop < $CLIloops)
|
||||
|
||||
$stat_count++;
|
||||
$master_loop++;
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /00$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct' WHERE process='$script_name' and server_ip='$VARserver_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
}
|
||||
|
||||
$dbhA->disconnect();
|
||||
@@ -7401,6 +7415,14 @@ sub call_quota_logging
|
||||
##### END Call Quota Lead Ranking logging #####
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$VARserver_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
##### BEGIN math divisor sub #####
|
||||
sub MathZDC
|
||||
{
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
# It is good practice to keep this program running by placing the associated
|
||||
# KEEPALIVE script running every minute to ensure this program is always running
|
||||
#
|
||||
# Copyright (C) 2025 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGELOG:
|
||||
# 50125-1201 - Changed dial timeout to 120 seconds from 180 seconds
|
||||
@@ -162,10 +162,12 @@
|
||||
# 240731-0814 - Fix for 2nd DB connection timing out while running
|
||||
# 240917-1719 - Change multiple after-call processing to only run for active_voicemail_server
|
||||
# 251205-1455 - Added SHARED_ADAPT_PERCENTMAX option
|
||||
# 260515-1937 - Added internal logging
|
||||
#
|
||||
|
||||
$build='251205-1455';
|
||||
$build='260515-1937';
|
||||
$script='AST_VDauto_dial';
|
||||
$script_name = 'AST_VDauto_dial.pl';
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
{
|
||||
@@ -298,6 +300,8 @@ or die "Couldn't connect to database: " . DBI->errstr;
|
||||
$dbhC = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER '.$build; &internal_logger;
|
||||
|
||||
### 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,vicidial_recording_limit,asterisk_version,routing_prefix FROM servers where server_ip = '$server_ip';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
@@ -418,6 +422,8 @@ while($one_day_interval > 0)
|
||||
{
|
||||
$endless_loop=5760000; # 30 days minutes at XXX seconds per loop
|
||||
$stat_count=1;
|
||||
$iLog_ct=0;
|
||||
$iLog_calls=0;
|
||||
|
||||
while($endless_loop > 0)
|
||||
{
|
||||
@@ -2405,6 +2411,7 @@ while($one_day_interval > 0)
|
||||
# usleep(1*50*1000);
|
||||
usleep(1*$per_call_delay*1000);
|
||||
$calls_placed++;
|
||||
$iLog_calls++;
|
||||
}
|
||||
}
|
||||
$call_CMPIPct++;
|
||||
@@ -5288,6 +5295,16 @@ while($one_day_interval > 0)
|
||||
$stmtA = "INSERT INTO vicidial_shared_log SET log_time='$now_date',total_agents='$shared_dial_camp_override',debug_output='BUILD: $build\n$debug_shared_output$temp_dead_debug',campaign_id='-SHARE-',server_ip='$VARserver_ip';";
|
||||
$affected_rows = $dbhA->do($stmtA);
|
||||
}
|
||||
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /00$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct Events: $iLog_calls' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5887,6 +5904,14 @@ sub aad_output
|
||||
}
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
# subroutine to parse the asterisk version
|
||||
# and return a hash with the various part
|
||||
sub parse_asterisk_version
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#
|
||||
# Should only be run on one server in a multi-server Asterisk/VICIDIAL cluster
|
||||
#
|
||||
# Copyright (C) 2023 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGELOG:
|
||||
# 61115-1246 - First build, framework setup, non-functional
|
||||
@@ -55,6 +55,7 @@
|
||||
# 230830-1056 - Changed outbound_calls_per_second max to allow up to 1000 CPS
|
||||
# 231116-0916 - Added hopper_hold_inserts option
|
||||
# 231129-0905 - Added vicidial_phone_number_call_daily_counts updates/inserts
|
||||
# 260515-1941 - Added internal logging
|
||||
#
|
||||
|
||||
### begin parsing run-time options ###
|
||||
@@ -124,6 +125,7 @@ $US='__';
|
||||
$MT[0]='';
|
||||
$RECcount=''; ### leave blank for no REC count
|
||||
$RECprefix='7'; ### leave blank for no REC prefix
|
||||
$script_name = 'AST_VDauto_dial_FILL.pl';
|
||||
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
@@ -180,6 +182,8 @@ 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;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; &internal_logger;
|
||||
|
||||
### 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 FROM servers where server_ip = '$server_ip';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
@@ -241,6 +245,7 @@ if ($non_latin > 0)
|
||||
$sthA->finish();
|
||||
}
|
||||
|
||||
$iLog_ct=0;
|
||||
$one_day_interval = 12; # 1 month loops for one year
|
||||
while($one_day_interval > 0)
|
||||
{
|
||||
@@ -1612,6 +1617,16 @@ while($one_day_interval > 0)
|
||||
&get_time_now;
|
||||
}
|
||||
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /00$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
$stat_count++;
|
||||
}
|
||||
|
||||
@@ -1785,3 +1800,12 @@ sub parse_asterisk_version
|
||||
|
||||
return ( %ast_ver_hash );
|
||||
}
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,11 @@
|
||||
# 240420-2246 - Added ConfBridge code
|
||||
# 240516-2149 - Allow for ALT start_call_url, added --version flag
|
||||
# 260403-2253 - Added vicidial_max_inbound_cache logging
|
||||
# 260515-1935 - Added internal logging
|
||||
#
|
||||
|
||||
$build = '260403-2253';
|
||||
$build = '260515-1933';
|
||||
$script_name = 'AST_VDremote_agents.pl';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
@@ -190,6 +192,7 @@ 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;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER '.$build; &internal_logger;
|
||||
|
||||
#############################################
|
||||
##### Gather system_settings #####
|
||||
@@ -252,6 +255,7 @@ if ($run_check > 0)
|
||||
|
||||
#$one_day_interval = 12; # 1 month loops for one year
|
||||
$one_day_interval = 1; # 1 day
|
||||
$iLog_ct=0;
|
||||
while($one_day_interval > 0)
|
||||
{
|
||||
#$endless_loop=5760000; # 30 days minutes at XXX seconds per loop
|
||||
@@ -1253,7 +1257,7 @@ while($one_day_interval > 0)
|
||||
usleep(1*$loop_delay*1000);
|
||||
|
||||
$endless_loop--;
|
||||
if($DB){print STDERR "\nloop counter: |$endless_loop|$one_day_interval| |$loop_delay|\n";}
|
||||
if($DB){print STDERR "\nloop counter: |$endless_loop|$one_day_interval|$iLog_ct| |$loop_delay|\n";}
|
||||
|
||||
### putting a blank file called "VDAD.kill" in the directory will automatically safely kill this program
|
||||
if (-e "$PATHhome/VDAD.kill")
|
||||
@@ -1265,6 +1269,16 @@ while($one_day_interval > 0)
|
||||
}
|
||||
|
||||
$bad_grabber_counter=0;
|
||||
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /00$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1402,6 +1416,15 @@ sub event_logger
|
||||
}
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
|
||||
##### BEGIN Call Quota Lead Ranking logging #####
|
||||
sub call_quota_logging
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# This program only needs to be run by one server
|
||||
#
|
||||
# Copyright (C) 2022 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 60711-0945 - Changed to DBI by Marin Blu
|
||||
@@ -48,11 +48,14 @@
|
||||
# 210523-2321 - Added optional check for qa_data duplicates, -qm-qa-duplicate-check
|
||||
# 220206-0714 - Added new -roll-back-preview-skips function to roll back the last_local_call_time and called_count for leads that were previewed and not dialed
|
||||
# 250625-2329 - Added --wait-pause-code-swap option
|
||||
# 260515-2216 - Added internal logging
|
||||
#
|
||||
|
||||
# constants
|
||||
$US='__';
|
||||
$MT[0]='';
|
||||
$script_name = 'AST_cleanup_agent_log.pl';
|
||||
$start_sec = time();
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
@@ -472,6 +475,8 @@ 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;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; &internal_logger;
|
||||
|
||||
#############################################
|
||||
##### START QUEUEMETRICS LOGGING LOOKUP #####
|
||||
$stmtA = "SELECT enable_queuemetrics_logging,queuemetrics_server_ip,queuemetrics_dbname,queuemetrics_login,queuemetrics_pass,queuemetrics_log_id,queuemetrics_eq_prepend,queuemetrics_loginout,queuemetrics_dispo_pause,queuemetrics_pause_type FROM system_settings;";
|
||||
@@ -3088,10 +3093,18 @@ if ($enable_queuemetrics_logging > 0)
|
||||
|
||||
|
||||
|
||||
# update internal process log
|
||||
$now_sec = time();
|
||||
$run_sec = ($now_sec - $start_sec);
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='finished', stage='Run seconds: $run_sec' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
|
||||
|
||||
|
||||
if ($DB) {print STDERR "\nDONE\n";}
|
||||
|
||||
if ($DB) {print STDERR "\nDONE\n";}
|
||||
|
||||
|
||||
|
||||
@@ -3114,3 +3127,12 @@ sub event_logger
|
||||
close(Lout);
|
||||
$event_string='';
|
||||
}
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
# script's crontab entry that does some of these functions:
|
||||
# AST_conf_update.pl --no-vc-3way-check
|
||||
#
|
||||
# Copyright (C) 2023 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# 100811-2119 - First build, based upon AST_conf_update.pl script
|
||||
# 100928-1506 - Changed from hard-coded 60 minute limit to servers.vicidial_recording_limit
|
||||
@@ -23,6 +23,7 @@
|
||||
# 200413-1356 - Fix for \n\n at the end of PING commands causing errors in AMI
|
||||
# 231117-2255 - Added AMI version 5 compatibility
|
||||
# 231118-1110 - Added override option of up to Xtimeout9 for 3WAY_... leave-3way sessions
|
||||
# 260515-1943 - Added internal logging
|
||||
#
|
||||
|
||||
# constants
|
||||
@@ -32,6 +33,7 @@ $US='__';
|
||||
$MT[0]='';
|
||||
$loops = '100000';
|
||||
$CLIdelay = '3';
|
||||
$script_name = 'AST_conf_update_3way.pl';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
@@ -145,6 +147,8 @@ use Net::Telnet ();
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; &internal_logger;
|
||||
|
||||
### 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,vicidial_recording_limit,asterisk_version,vd_server_logs FROM servers where server_ip = '$server_ip';";
|
||||
if ($DB) {print "|$stmtA|\n";}
|
||||
@@ -210,6 +214,7 @@ $event_string = "AST_conf_update_3way.pl script starting: $year-$mon-$mday $hour
|
||||
&event_logger;
|
||||
|
||||
$loop_counter=0;
|
||||
$iLog_ct=0;
|
||||
|
||||
while ($loops > $loop_counter)
|
||||
{
|
||||
@@ -490,6 +495,16 @@ while ($loops > $loop_counter)
|
||||
sleep(10);
|
||||
$loop_counter=9999999;
|
||||
}
|
||||
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /00$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -557,3 +572,11 @@ sub event_logger
|
||||
}
|
||||
$event_string='';
|
||||
}
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
@@ -11,12 +11,14 @@
|
||||
# 220414-1210 - Initial build
|
||||
# 250305-2104 - Fix for missing vicidial_confbridges limit purge code
|
||||
# 250326-2102 - Fixes for ConfBridge issues
|
||||
# 260515-1939 - Added internal logging
|
||||
#
|
||||
|
||||
# constants
|
||||
$DB=0; # Debug flag, set to 0 for no debug messages, lots of output
|
||||
$DBX=0;
|
||||
$run_check=1; # concurrency check
|
||||
$script_name = 'AST_conf_update_screen.pl';
|
||||
|
||||
# loop time in seconds
|
||||
$loop_time = 0.4;
|
||||
@@ -124,6 +126,8 @@ if (try_load($module))
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; &internal_logger;
|
||||
|
||||
### 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,conf_engine,conf_update_interval,vicidial_recording_limit FROM servers where server_ip = '$server_ip';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
@@ -248,6 +252,7 @@ else
|
||||
### BEGIN manager event handling for asterisk version >= 13
|
||||
$endless_loop = 1;
|
||||
$loop_count = 0;
|
||||
$iLog_ct=0;
|
||||
|
||||
# get the number of microseconds the loop is supposed to take
|
||||
$loop_time_usec = $loop_time * 1000000;
|
||||
@@ -795,7 +800,16 @@ else
|
||||
# sleep it
|
||||
usleep($sleep_usec);
|
||||
}
|
||||
|
||||
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /00$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -856,6 +870,14 @@ sub event_logger
|
||||
}
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
|
||||
# subroutine to parse the asterisk version
|
||||
# and return a hash with the various part
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# !!!!!!!! IMPORTANT !!!!!!!!!!!!!!!!!!
|
||||
# THIS SCRIPT SHOULD ONLY BE RUN ON ONE SERVER ON YOUR CLUSTER
|
||||
#
|
||||
# Copyright (C) 2025 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 60717-1214 - changed to DBI by Marin Blu
|
||||
@@ -38,6 +38,7 @@
|
||||
# 240709-1300 - Added Validate XFER vicidial_auto_calls: "--check-xfers" flag
|
||||
# 250914-1537 - Added archiving of recording_live table
|
||||
# 251003-0837 - Added --preserve-dtmf flag (DTMF logs would then be kept for 1-2 days)
|
||||
# 260515-2212 - Added internal logging
|
||||
#
|
||||
|
||||
$session_flush=0;
|
||||
@@ -48,6 +49,8 @@ $stuck_listsSQL='';
|
||||
$preserve_dtmf=0;
|
||||
$check_xfers=0;
|
||||
$vicidial_recording_limit=60;
|
||||
$script_name = 'AST_flush_DBqueue.pl';
|
||||
$start_sec = time();
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
@@ -303,6 +306,8 @@ 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;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; &internal_logger;
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT vd_server_logs,vicidial_recording_limit FROM servers where server_ip = '$VARserver_ip';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
@@ -1127,7 +1132,24 @@ if ($rl_count > 0)
|
||||
}
|
||||
### END archive recording_live that are FINISHED ###
|
||||
|
||||
# update internal process log
|
||||
$now_sec = time();
|
||||
$run_sec = ($now_sec - $start_sec);
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='finished', stage='Run seconds: $run_sec' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
|
||||
|
||||
$dbhA->disconnect();
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
# 210407-2009 - Added Event handlers for new manager events
|
||||
# 251007-2110 - Added code for recording_dtmf_detection and recording_dtmf_muting
|
||||
# 260327-1516 - Added support for PJSIP (requires patched Asterisk 18+)
|
||||
# 260515-1933 - Added internal logging
|
||||
#
|
||||
|
||||
# constants
|
||||
@@ -36,6 +37,7 @@ $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;
|
||||
$script_name = 'AST_manager_listen_AMI2.pl';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
@@ -128,6 +130,8 @@ if (try_load($module))
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; &internal_logger;
|
||||
|
||||
### 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;
|
||||
@@ -264,6 +268,8 @@ else
|
||||
{
|
||||
### BEGIN manager event handling for asterisk version >= 13
|
||||
$endless_loop = 1;
|
||||
$iLog_ct=0;
|
||||
$iLog_calls=0;
|
||||
while($endless_loop > 0)
|
||||
{
|
||||
$breakout = 1;
|
||||
@@ -453,6 +459,7 @@ else
|
||||
# handle the event
|
||||
$retcode = handle_event( %event_hash );
|
||||
$last_event_epoch = time();
|
||||
$iLog_calls++;
|
||||
}
|
||||
elsif ( ( exists($event_hash{"Response"}) ) && ( exists($event_hash{"Ping"}) ) )
|
||||
{
|
||||
@@ -470,6 +477,15 @@ else
|
||||
$event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|";
|
||||
&event_logger;
|
||||
}
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /00$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct Events: $iLog_calls' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
}
|
||||
|
||||
usleep(1*100*1000);
|
||||
@@ -1107,6 +1123,14 @@ sub dtmf_logger
|
||||
}
|
||||
}
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
# subroutine to parse the asterisk version
|
||||
# and return a hash with the various part
|
||||
sub parse_asterisk_version
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
# scalability over just using a single process. Also, this means that a single
|
||||
# action execution lock cannot bring the entire system down.
|
||||
#
|
||||
# Copyright (C) 2017 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2025 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 50823-1514 - Added commandline debug options with debug printouts
|
||||
@@ -31,6 +31,7 @@
|
||||
# 91129-2146 - removed SELECT STAR and formatting fixes
|
||||
# 141113-1356 - Added more logging, check for number of running instances, processing of QUEUE but not SENT commands
|
||||
# 170920-1419 - Fix for issue with recordings beginning with CALLID variable
|
||||
# 260515-1940 - Added internal logging
|
||||
#
|
||||
|
||||
$|++;
|
||||
@@ -40,6 +41,7 @@ use Getopt::Long;
|
||||
use Time::HiRes ('gettimeofday','usleep','sleep'); # necessary to have perl sleep command of less than one second
|
||||
|
||||
my $run_check=1; # concurrency check
|
||||
my $script_name = 'AST_manager_send.pl';
|
||||
|
||||
# constants and globals
|
||||
my $servConf;
|
||||
@@ -102,6 +104,8 @@ $conf{VARDB_port} = '3306' unless ($conf{VARDB_port});
|
||||
my $dbhA = DBI->connect("DBI:mysql:" . $conf{VARDB_database} . ":" . $conf{VARDB_server} . ":" . $conf{VARDB_port},
|
||||
$conf{VARDB_user}, $conf{VARDB_pass}) or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
my $action='start'; my $stage='LOGGED INTO MYSQL SERVER'; my $server_ip = $conf{VARserver_ip}; &internal_logger;
|
||||
|
||||
### Grab Server values from the database
|
||||
$servConf = getServerConfig($dbhA, $conf{VARserver_ip});
|
||||
$SYSLOG = 1 if ($servConf->{vd_server_logs} =~ /Y/);
|
||||
@@ -130,6 +134,8 @@ while ($one_day_interval > 0)
|
||||
my $endless_loop = 1728000; # 2 days at .10 seconds per loop
|
||||
my $affected_rows;
|
||||
my $NEW_actions;
|
||||
my $iLog_ct=0;
|
||||
my $iLog_calls=0;
|
||||
while ($endless_loop > 0)
|
||||
{
|
||||
my $stmtA = "SELECT count(*) from vicidial_manager where server_ip = '" . $conf{VARserver_ip} . "' and status = 'NEW';";
|
||||
@@ -277,6 +283,7 @@ while ($one_day_interval > 0)
|
||||
eventLogger($conf{'PATHlogs'}, 'process', $event_string);
|
||||
}
|
||||
$processed_actions++;
|
||||
$iLog_calls++;
|
||||
}
|
||||
$sthA->finish();
|
||||
}
|
||||
@@ -285,11 +292,22 @@ while ($one_day_interval > 0)
|
||||
{
|
||||
### sleep for 1 hundredth of a second if just send an ACTION
|
||||
usleep(1*10*1000);
|
||||
$iLog_ct++;
|
||||
}
|
||||
else
|
||||
{
|
||||
### sleep for 10 hundredths of a second if no actions sent
|
||||
usleep(1*100*1000);
|
||||
$iLog_ct++;
|
||||
}
|
||||
|
||||
# update internal process log
|
||||
if ($iLog_ct =~ /000$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct Events: $iLog_calls' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
$endless_loop--;
|
||||
@@ -438,3 +456,11 @@ sub logDate
|
||||
}
|
||||
|
||||
### End of subs
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
my $stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
# CHANGES
|
||||
# 190528-1304 - Copied AST_manager_listen_AMI2.pl to make the initial version
|
||||
# 260327-1509 - Added support for PJSIP (requires patched Asterisk 18+)
|
||||
# 260515-1934 - Added internal logging
|
||||
#
|
||||
|
||||
# constants
|
||||
@@ -21,6 +22,7 @@ $run_check=1; # concurrency check
|
||||
$last_keepalive_epoch = time();
|
||||
$keepalive_skips=0;
|
||||
$ami_user='sipcron';
|
||||
$script_name = 'AST_manager_sip_AMI2.pl';
|
||||
|
||||
### begin parsing run-time options ###
|
||||
if (length($ARGV[0])>1)
|
||||
@@ -113,6 +115,8 @@ if (try_load($module))
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; &internal_logger;
|
||||
|
||||
### 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;
|
||||
@@ -225,6 +229,8 @@ $keep_alive_sec = 30;
|
||||
$keep_alive_skips = 0;
|
||||
$keep_alive_response = 1;
|
||||
$keep_alive_no_responses = 0;
|
||||
$iLog_ct=0;
|
||||
$iLog_calls=0;
|
||||
|
||||
%ast_ver_str = parse_asterisk_version($asterisk_version);
|
||||
if (( $ast_ver_str{major} = 1 ) && ($ast_ver_str{minor} < 13))
|
||||
@@ -427,6 +433,7 @@ else
|
||||
# handle the event
|
||||
$retcode = handle_event( %event_hash );
|
||||
$last_event_epoch = time();
|
||||
$iLog_calls++;
|
||||
}
|
||||
elsif ( ( exists($event_hash{"Response"}) ) && ( exists($event_hash{"Ping"}) ) )
|
||||
{
|
||||
@@ -444,6 +451,16 @@ else
|
||||
$event_string="Asterisk server shutting down, PROCESS KILLED... EXITING|ONE DAY INTERVAL:$one_day_interval|";
|
||||
&event_logger;
|
||||
}
|
||||
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /00$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct Events: $iLog_calls' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
}
|
||||
|
||||
usleep(1*100*1000);
|
||||
@@ -713,6 +730,15 @@ sub manager_output_logger
|
||||
}
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
|
||||
# subroutine to parse the asterisk version
|
||||
# and return a hash with the various part
|
||||
sub parse_asterisk_version
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# This script uses the Asterisk Manager interface to update the live_channels
|
||||
# tables and verify the parked_channels table in the asterisk MySQL database
|
||||
#
|
||||
# Copyright (C) 2025 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGES
|
||||
# 170915-2110 - Initial version for Asterisk 13, based upon AST_update.pl
|
||||
@@ -21,12 +21,14 @@
|
||||
# 220310-1136 - Fix for issue dealing with bad carrier 'P-Asserted-Identity' input
|
||||
# 251008-2114 - Added code for recording_dtmf_detection and recording_dtmf_muting
|
||||
# 251203-2218 - Added server_live_partitions inserts/updates
|
||||
# 260515-1939 - Added internal logging
|
||||
#
|
||||
|
||||
# constants
|
||||
$DB=0; # Debug flag, set to 0 for no debug messages, lots of output
|
||||
$DBX=0;
|
||||
$run_check=1; # concurrency check
|
||||
$script_name = 'AST_update_AMI2.pl';
|
||||
|
||||
# loop time in seconds
|
||||
$loop_time = 0.4;
|
||||
@@ -159,6 +161,8 @@ if (try_load($module))
|
||||
$dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER '.$build; &internal_logger;
|
||||
|
||||
### 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;
|
||||
@@ -341,6 +345,8 @@ else
|
||||
### BEGIN manager event handling for asterisk version >= 13
|
||||
$endless_loop = 1;
|
||||
$loop_count = 0;
|
||||
$iLog_ct=0;
|
||||
$iLog_calls=0;
|
||||
|
||||
# get the number of microseconds the loop is supposed to take
|
||||
$loop_time_usec = $loop_time * 1000000;
|
||||
@@ -718,6 +724,15 @@ else
|
||||
|
||||
}
|
||||
}
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /000$|500$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1870,3 +1885,11 @@ sub get_disk_rw
|
||||
|
||||
return ( $reads, $writes );
|
||||
}
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
@@ -106,6 +106,7 @@
|
||||
# 250928-1556 - Added hosted_settings dialplan variable
|
||||
# 260327-0824 - Fixes for PJSIP compatibility
|
||||
# 260424-1644 - Fix for rare Auto-Alt Dial issue
|
||||
# 260515-1936 - Added internal logging
|
||||
#
|
||||
|
||||
# defaults for PreFork
|
||||
@@ -119,6 +120,7 @@ $VARfastagi_log_checkforwait = '60';
|
||||
$DB=0;
|
||||
$DBX=0;
|
||||
$ADB=0;
|
||||
$script_name = 'FastAGI_log.pl';
|
||||
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
@@ -180,6 +182,12 @@ use DBI;
|
||||
$dbhB = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER';
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$VARserver_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhB->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtB = "SELECT vd_server_logs,asterisk_version FROM servers where server_ip = '$VARserver_ip';";
|
||||
$sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
|
||||
# Copyright (C) 2024 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Joe Johnson, Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# VD_email_inbound.pl
|
||||
# This script is responsible for assigning transferred and new emails to
|
||||
@@ -27,8 +27,11 @@ $PATHconf = '/etc/astguiclient.conf';
|
||||
# 190216-0810 - Fix for user-group, email-group and campaign allowed/permissions matching issues
|
||||
# 191017-2043 - Added filtered routing options
|
||||
# 240219-1526 - Added daily_limit in-group parameter
|
||||
# 260515-1941 - Added internal logging
|
||||
#
|
||||
|
||||
$script_name = 'VD_email_inbound.pl';
|
||||
|
||||
if ($ARGV[0]=~/--help/)
|
||||
{
|
||||
print "VD_email_inbound.pl\n";
|
||||
@@ -107,6 +110,8 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA
|
||||
$dbhB = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VARDB_user", "$VARDB_pass")
|
||||
or die "Couldn't connect to database: " . DBI->errstr;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER'; $server_ip=$VARserver_ip; &internal_logger;
|
||||
|
||||
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
|
||||
$year = ($year + 1900);
|
||||
$mon++;
|
||||
@@ -155,7 +160,7 @@ $BDtsSQLdate = "$Byear$Bmon$Bmday$Bhour$Bmin$Bsec";
|
||||
#$vig_rslt=$dbhA->prepare($vig_stmt);
|
||||
#$vig_rslt->execute();
|
||||
|
||||
|
||||
$iLog_ct=0;
|
||||
for ($i=0; $i<=1000000; $i++)
|
||||
{
|
||||
$vci=0;
|
||||
@@ -233,6 +238,16 @@ for ($i=0; $i<=1000000; $i++)
|
||||
|
||||
if ($email_ct>0) {AssignAgents();} else {if ($ARGV[0]=~/debug/i) {print "**** NO EMAILS TO QUEUE ****\n";}}
|
||||
}
|
||||
|
||||
# update internal process log
|
||||
$iLog_ct++;
|
||||
if ($iLog_ct =~ /000$/)
|
||||
{
|
||||
$stmtA = "UPDATE vicidial_internal_log SET up_time=NOW(), action='running', stage='Loops: $iLog_ct' WHERE process='$script_name' and server_ip='$server_ip' order by db_time desc limit 1;";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
usleep(100000);
|
||||
}
|
||||
|
||||
@@ -407,3 +422,11 @@ sub mysql_error_logging
|
||||
}
|
||||
$one_mysql_log=0;
|
||||
}
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$server_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# operate as intended
|
||||
#
|
||||
#
|
||||
# Copyright (C) 2013 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
# Copyright (C) 2026 Matt Florell <vicidial@gmail.com> LICENSE: AGPLv2
|
||||
#
|
||||
# CHANGES
|
||||
#
|
||||
@@ -16,11 +16,13 @@
|
||||
# 90506-1443 - mikec - Added the T option to the asterisk command. This enables timestamping.
|
||||
# 91210-1500 - mattf - Added datetimestamp to astshell screen
|
||||
# 131022-1659 - mattf - Added CLI help display
|
||||
# 260515-1951 - Added internal logging
|
||||
#
|
||||
|
||||
$build = '131022-1659';
|
||||
$build = '260515-1951';
|
||||
# default path to astguiclient configuration file:
|
||||
$PATHconf = '/etc/astguiclient.conf';
|
||||
$script_name = 'start_asterisk_boot.pl';
|
||||
|
||||
open(conf, "$PATHconf") || die "can't open $PATHconf: $!\n";
|
||||
@conf = <conf>;
|
||||
@@ -105,6 +107,8 @@ 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;
|
||||
|
||||
$action='start'; $stage='LOGGED INTO MYSQL SERVER '.$build; &internal_logger;
|
||||
|
||||
### Grab Server values from the database
|
||||
$stmtA = "SELECT vd_server_logs FROM servers where server_ip = '$VARserver_ip';";
|
||||
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
|
||||
@@ -172,3 +176,12 @@ $affected_rows = $dbhA->do($stmtA);
|
||||
|
||||
|
||||
exit;
|
||||
|
||||
|
||||
sub internal_logger
|
||||
{
|
||||
$stmtA = "INSERT INTO vicidial_internal_log SET db_time=NOW(), up_time=NOW(), process='$script_name', server_ip='$VARserver_ip', action='$action', stage='$stage';";
|
||||
if($DB){print STDERR "|$stmtA|";}
|
||||
my $affected_rows = $dbhA->do($stmtA);
|
||||
if($DB){print STDERR "$affected_rows|\n";}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user