Added oldest_logs_date display field to system settings

Added --vlog-daily option to archive log tables script

git-svn-id: svn://192.168.202.10@2416 3d104415-ff17-0410-8863-d5cf3c621b8a
This commit is contained in:
mattf
2015-11-25 05:22:14 +00:00
parent 4fca85414c
commit 8abd73427e
4 changed files with 81 additions and 10 deletions
+68 -5
View File
@@ -1,6 +1,6 @@
#!/usr/bin/perl
#
# ADMIN_archive_log_tables.pl
# ADMIN_archive_log_tables.pl version 2.12
#
# This script is designed to put all records from call_log, vicidial_log and
# vicidial_agent_log in relevant _archive tables and delete records in original
@@ -41,6 +41,7 @@
# 150107-2308 - Added vicidial_api_log to daily process
# 150712-2208 - Added vicidial_dtmf_log
# 151109-1646 - Added --carrier-daily flag, only active if --daily flag is also used
# 151124-2252 - Added --vlog-daily flag, only active if --daily flag is also used, Also added system_settings date
#
$CALC_TEST=0;
@@ -61,6 +62,7 @@ if (length($ARGV[0])>1)
print "allowed run time options:\n";
print " [--daily] = only archives call_log, vicidial_log_extended and vicidial_dial_log tables, only last 24 hours kept\n";
print " [--carrier-daily] = will also archive the vicidial_carrier_log table when --daily is run\n";
print " [--vlog-daily] = will also archive the vicidial_log table when --daily is run\n";
print " [--days=XX] = number of days to archive past, default is 732(2 years)\n";
print " [--months=XX] = number of months to archive past, default is 24(2 years) If 'days' used then 'months' ignored\n";
print " [--closer-log] = archive vicidial_closer_log records\n";
@@ -97,6 +99,12 @@ if (length($ARGV[0])>1)
if ($Q < 1)
{print "\n----- CARRIER DAILY OPTION -----\n\n";}
}
if ($args =~ /--vlog-daily/i)
{
$vlog_daily=1;
if ($Q < 1)
{print "\n----- VLOG DAILY OPTION -----\n\n";}
}
}
if ($args =~ /--months=/i)
{
@@ -491,6 +499,61 @@ if (!$T)
##### END vicidial_carrier_log DAILY processing #####
}
if ($vlog_daily)
{
##### BEGIN vicidial_log DAILY processing #####
$stmtA = "SELECT count(*) from vicidial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$sthArows=$sthA->rows;
if ($sthArows > 0)
{
@aryA = $sthA->fetchrow_array;
$vicidial_log_count = $aryA[0];
}
$sthA->finish();
$stmtA = "SELECT count(*) from vicidial_log_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_archive_count = $aryA[0];
}
$sthA->finish();
if (!$Q) {print "\nProcessing vicidial_log table... ($vicidial_log_count|$vicidial_log_archive_count)\n";}
$stmtA = "INSERT IGNORE INTO vicidial_log_archive SELECT * from vicidial_log;";
$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_archive table \n";}
$rv = $sthA->err();
if (!$rv)
{
$stmtA = "DELETE FROM vicidial_log 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 table \n";}
$stmtA = "optimize table vicidial_log;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
$stmtA = "optimize table vicidial_log_archive;";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
##### END vicidial_log DAILY processing #####
}
### calculate time to run script ###
$secY = time();
$secZ = ($secY - $secX);
@@ -1107,8 +1170,6 @@ if (!$T)
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
}
##### vicidial_carrier_log
@@ -1314,8 +1375,10 @@ if (!$T)
}
#$dbhA->disconnect();
#print "$del_time\n\n";
$stmtA = "UPDATE system_settings SET oldest_logs_date='$del_time';";
$sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr;
$sthA->execute or die "executing: $stmtA ", $dbhA->errstr;
}
### calculate time to run script ###
+3 -2
View File
@@ -1623,7 +1623,8 @@ agent_whisper_enabled ENUM('0','1') default '0',
user_hide_realtime_enabled ENUM('0','1') default '0',
custom_reports_use_slave_db VARCHAR(2000) default '',
usacan_phone_dialcode_fix ENUM('0','1') default '0',
cache_carrier_stats_realtime ENUM('0','1') default '0'
cache_carrier_stats_realtime ENUM('0','1') default '0',
oldest_logs_date DATETIME
) ENGINE=MyISAM;
CREATE TABLE vicidial_campaigns_list_mix (
@@ -3629,4 +3630,4 @@ UPDATE vicidial_configuration set value='1766' where name='qc_database_version';
UPDATE system_settings set vdc_agent_api_active='1';
UPDATE system_settings SET db_schema_version='1436',db_schema_update_date=NOW(),reload_timestamp=NOW();
UPDATE system_settings SET db_schema_version='1437',db_schema_update_date=NOW(),reload_timestamp=NOW();
+4
View File
@@ -375,3 +375,7 @@ UNIQUE KEY vicidial_html_cache_stats_key (stats_type,stats_id)
ALTER TABLE system_settings ADD cache_carrier_stats_realtime ENUM('0','1') default '0';
UPDATE system_settings SET db_schema_version='1436',db_schema_update_date=NOW() where db_schema_version < 1436;
ALTER TABLE system_settings ADD oldest_logs_date DATETIME;
UPDATE system_settings SET db_schema_version='1437',db_schema_update_date=NOW() where db_schema_version < 1437;
+6 -3
View File
@@ -3633,12 +3633,13 @@ else
# 151030-0636 - Added usacan_phone_dialcode_fix system setting option, executed by keepalive at timeclock end of day
# 151104-1518 - Added am_message_wildcards campaign option and amm-multi admin page
# 151124-1141 - Added cache_carrier_stats_realtime settings option
# 151125-0010 - Added oldest_logs_date display field to system settings
#
# 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.12-519a';
$build = '151124-1141';
$admin_version = '2.12-520a';
$build = '151125-0010';
$STARTtime = date("U");
$SQLdate = date("Y-m-d H:i:s");
@@ -31692,7 +31693,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 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 from system_settings;";
$rslt=mysql_to_mysqli($stmt, $link);
$row=mysqli_fetch_row($rslt);
$version = $row[0];
@@ -31834,6 +31835,7 @@ if ($ADD==311111111111111)
$user_hide_realtime_enabled = $row[136];
$usacan_phone_dialcode_fix = $row[137];
$cache_carrier_stats_realtime = $row[138];
$oldest_logs_date = $row[139];
if ($pass_hash_enabled > 0) {$pass_hash_enabled = 'ENABLED';}
else {$pass_hash_enabled = 'DISABLED';}
@@ -31929,6 +31931,7 @@ if ($ADD==311111111111111)
echo "<tr bgcolor=#B6D3FC><td align=right>"._QXZ("Agents Calls Reset").": </td><td align=left><select size=1 name=agents_calls_reset><option>1</option><option>0</option><option selected>$agents_calls_reset</option></select>$NWB#settings-agents_calls_reset$NWE</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>"._QXZ("Timeclock Last Auto Logout").": </td><td align=left> $timeclock_last_reset_date</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>"._QXZ("Oldest Logs Date").": </td><td align=left> $oldest_logs_date</td></tr>\n";
echo "<tr bgcolor=#B6D3FC><td align=right>"._QXZ("Agent Screen Header Date Format").": </td><td align=left><select size=1 name=vdc_header_date_format>\n";
echo "<option>MS_DASH_24HR 2008-06-24 23:59:59</option>\n";
echo "<option>US_SLASH_24HR 06/24/2008 23:59:59</option>\n";