]> _ Git - remote-logging.git/commitdiff
client: don't transfer rotated and/or empty log files
authormivirl <>
Sun, 2 Jun 2024 03:02:20 +0000 (22:02 -0500)
committermivirl <>
Sun, 2 Jun 2024 03:02:20 +0000 (22:02 -0500)
src/client.pl

index 7b17fba7c2c2584629ffe872bbbd25cebcd2fa57..27b4cacf14429817b63aacdc9aabb39211a9a9b8 100644 (file)
@@ -57,9 +57,15 @@ sub ns_systemFH {
 }
 
 sub get_files_recursively {
-    my @dirs = @_;
-    my @files = ns_system('./busybox', 'find', @dirs, '-type', 'f');
+    my ($dir, $includeempty) = @_;
+    my @extra_args = ();
+    if (!$includeempty) {
+        push @extra_args, '-size', '+0';
+    }
+
+    my @files = ns_system('./busybox', 'find', $dir, '-type', 'f', @extra_args);
     map { chomp $_ } @files;
+
     return @files;
 }
 
@@ -327,6 +333,11 @@ foreach my $logfile (get_files_recursively('/var/log')) {
         push @binary_logfiles, $logfile;
     }
 }
+# Filter out some files
+@binary_logfiles = grep { ! ( m|/var/log/journal/.+\.journal| ||        # Binary journal files
+    # m|/var/log/journal/[0-9a-f]+/[a-z0-9-]+@[0-9a-f-]*\.journal| ||   # Rotated binary journal files
+    m|/var/log/.+\.\d\.[gx]z|                                           # Rotated & compressed log files
+    ) } @binary_logfiles;
 
 # These files will be sent once
 send_file('/etc/crontab');         # Scheduled jobs