aboutsummaryrefslogtreecommitdiffstats
path: root/config/snort
diff options
context:
space:
mode:
authorbmeeks8 <bmeeks8@bellsouth.net>2014-10-08 16:34:26 -0400
committerbmeeks8 <bmeeks8@bellsouth.net>2014-10-08 16:34:26 -0400
commit492fd97587479b0c15a74d84b749cb974c183975 (patch)
treeecc19b9d240b3da7270fcde29b3f435985fc40d1 /config/snort
parent4fa9c97866c90b7bb84ff7b55579b646b53184f1 (diff)
downloadpfsense-packages-492fd97587479b0c15a74d84b749cb974c183975.tar.gz
pfsense-packages-492fd97587479b0c15a74d84b749cb974c183975.tar.bz2
pfsense-packages-492fd97587479b0c15a74d84b749cb974c183975.zip
Add code to cleanup rotated perfmon stats log files.
Diffstat (limited to 'config/snort')
-rw-r--r--config/snort/snort_check_cron_misc.inc31
1 files changed, 31 insertions, 0 deletions
diff --git a/config/snort/snort_check_cron_misc.inc b/config/snort/snort_check_cron_misc.inc
index 5e5be98a..72ede20c 100644
--- a/config/snort/snort_check_cron_misc.inc
+++ b/config/snort/snort_check_cron_misc.inc
@@ -75,6 +75,16 @@ function snort_check_dir_size_limit($snortloglimitsize) {
@file_put_contents("{$snort_log_dir}/alert", "");
}
+ // Cleanup any rotated perfmon stats logs
+ $files = array();
+ $list = glob("{$snort_log_dir}/*");
+ foreach ($list as $file) {
+ if (preg_match('/(^\d{4}-\d{2}-\d{2}[\.]?[\d+]?)/', basename($file), $matches))
+ $files[] = $snort_log_dir . "/" . $matches[1];
+ }
+ foreach ($files as $file)
+ unlink_if_exists($file);
+
// This is needed if snort is run as snort user
mwexec('/bin/chmod 660 {$snort_log_dir}/*', true);
@@ -197,6 +207,27 @@ if ($config['installedpackages']['snortglobal']['enable_log_mgmt'] == 'on') {
if ($prune_count > 0)
log_error(gettext("[Snort] Barnyard2 archived logs cleanup job removed {$prune_count} file(s) from {$snort_log_dir}/barnyard2/archive/..."));
}
+
+ // Prune aged-out perfmon stats logs if any exist
+ if ($value['stats_log_retention'] > 0) {
+ $now = time();
+ $files = array();
+ $list = glob("{$snort_log_dir}/*");
+ foreach ($list as $file) {
+ if (preg_match('/(^\d{4}-\d{2}-\d{2}[\.]?[\d+]?)/', basename($file), $matches))
+ $files[] = $snort_log_dir . "/" . $matches[1];
+ }
+ $prune_count = 0;
+ foreach ($files as $f) {
+ if (($now - filemtime($f)) > ($value['stats_log_retention'] * 3600)) {
+ $prune_count++;
+ unlink_if_exists($f);
+ }
+ }
+ unset($list, $files);
+ if ($prune_count > 0)
+ log_error(gettext("[Snort] perfmon stats logs cleanup job removed {$prune_count} file(s) from {$snort_log_dir}/..."));
+ }
}
}