[Logwatch-Devel] --hostname problem

Marco Alberoni m.alberoni at cineca.it
Fri Mar 25 04:24:59 MST 2005


Running logwatch 6.0.1 on a "var/log/messages" file with multiple hosts 
entries, I saw that the --hostname option didn't work at all. The 
problem is in the scripts/shared/onlyhost script: during the "messages" 
logfile preprocessing it is always executed with the parameter '' (that 
is void ma it's inserted in the ARGV list!), so the code:

#If called from a service config file it passes the param as an ARG
if ($#ARGV == 0) {      #put in or override the host id
         $hostname = $ARGV[0];
}

resets the $hostname variable and therefore all the logfile lines pass 
trough the filter.

In my opinion the solution is to apply the following change in logwatch.pl:

--- scripts/logwatch.pl 2005-02-28 12:55:34.000000000 +0100
+++ /tmp/logwatch.pl    2005-03-25 12:17:29.000000000 +0100
@@ -657,7 +657,11 @@
     foreach (sort keys %{$LogFileData{$LogFile}}) {
        my $cmd = $_;
        if ($cmd =~ s/^\d+-\*//) {
-         $FilterText .= ("| $PerlVersion $BaseDir" . 
"scripts/shared/$cmd '$LogFileData{$LogFile}{$_}'" );
+         if ("$LogFileData{$LogFile}{$_}" ne "") {
+            $FilterText .= ("| $PerlVersion $BaseDir" . 
"scripts/shared/$cmd '$LogFileData{$LogFile}{$_}'" );
+         } else {
+            $FilterText .= ("| $PerlVersion $BaseDir" . 
"scripts/shared/$cmd ");
+         }
        } elsif ($cmd =~ s/^\$//) {
           $ENV{$cmd} = $LogFileData{$LogFile}{$_};
           if ($Config{'debug'}>4) {

What do you think about?

-- 
                 Marco Alberoni
       CINECA - Systems management group



More information about the Logwatch-Devel mailing list