From dd14eb402e7ed67d1f5ad63415bf169a3e79135b Mon Sep 17 00:00:00 2001 From: Jonathan Prykop Date: Mon, 13 Apr 2015 17:59:12 -0500 Subject: [PATCH] RT#18834 Cacti integration [schema history fix and cleanup refactor] --- FS/FS/Cron/cacti_cleanup.pm | 19 ------------------- FS/FS/Cron/cleanup.pm | 18 +++++++++++++++++- FS/FS/Schema.pm | 2 +- FS/bin/freeside-daily | 13 +++---------- 4 files changed, 21 insertions(+), 31 deletions(-) delete mode 100644 FS/FS/Cron/cacti_cleanup.pm diff --git a/FS/FS/Cron/cacti_cleanup.pm b/FS/FS/Cron/cacti_cleanup.pm deleted file mode 100644 index f86262790..000000000 --- a/FS/FS/Cron/cacti_cleanup.pm +++ /dev/null @@ -1,19 +0,0 @@ -package FS::Cron::cacti_cleanup; -use base 'Exporter'; -use vars '@EXPORT_OK'; - -use FS::Record qw( qsearch ); -use Data::Dumper; - -@EXPORT_OK = qw( cacti_cleanup ); - -sub cacti_cleanup { - foreach my $export (qsearch({ - 'table' => 'part_export', - 'hashref' => { 'exporttype' => 'cacti' } - })) { - $export->cleanup; - } -} - -1; diff --git a/FS/FS/Cron/cleanup.pm b/FS/FS/Cron/cleanup.pm index 4c5cff278..6ec401398 100644 --- a/FS/FS/Cron/cleanup.pm +++ b/FS/FS/Cron/cleanup.pm @@ -2,8 +2,9 @@ package FS::Cron::cleanup; use base 'Exporter'; use vars '@EXPORT_OK'; use FS::queue; +use FS::Record qw( qsearch ); -@EXPORT_OK = qw( cleanup ); +@EXPORT_OK = qw( cleanup cleanup_before_backup ); # start janitor jobs sub cleanup { @@ -15,4 +16,19 @@ sub cleanup { $job->insert('_JOB'); } +sub cleanup_before_backup { + #remove outdated cacti_page entries + foreach my $export (qsearch({ + 'table' => 'part_export', + 'hashref' => { 'exporttype' => 'cacti' } + })) { + $export->cleanup; + } + #remove cache files + my $deldir = "$FS::UID::cache_dir/cache.$FS::UID::datasrc/"; + unlink <${deldir}.invoice*>; + unlink <${deldir}.letter*>; + unlink <${deldir}.CGItemp*>; +} + 1; diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 839a97176..29bbf7809 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -203,7 +203,7 @@ sub dbdef_dist { && ! /^legacy_cust_history$/ && ( ! /^queue(_arg|_depend|_stat)?$/ || ! $opt->{'queue-no_history'} ) && ! $tables_hashref_torrus->{$_} - && ! /^cacti_graph$/ + && ! /^cacti_page$/ } $dbdef->tables ) { diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily index bf9f17728..cb018d1df 100755 --- a/FS/bin/freeside-daily +++ b/FS/bin/freeside-daily @@ -83,15 +83,9 @@ export_batch_submit(%opt); use FS::Cron::agent_email qw(agent_email); agent_email(%opt); -#does nothing unless there are cacti imports -#should run before backup, no need to backup cacti imports -use FS::Cron::cacti_cleanup qw(cacti_cleanup); -cacti_cleanup(); - -my $deldir = "$FS::UID::cache_dir/cache.$FS::UID::datasrc/"; -unlink <${deldir}.invoice*>; -unlink <${deldir}.letter*>; -unlink <${deldir}.CGItemp*>; +#clears out cacti imports & deletes select database cache files +use FS::Cron::cleanup qw( cleanup cleanup_before_backup ); +cleanup_before_backup(); #backup should be last #you can skip this just by not having the config @@ -99,7 +93,6 @@ use FS::Cron::backup qw(backup); backup(); #except we'd rather not start cleanup jobs until the backup is done -use FS::Cron::cleanup qw(cleanup); cleanup(); $log->info('finish'); -- 2.11.0