Patch- HTML update +misc fixes
"Ross Becker" <[email protected]>
| Newsgroups | gmane.comp.log.logwatch.devel |
|---|---|
| Message-ID | <0CACC08CFE952344B50FB790528677C211C78E@exch2> |
Okay,
Here's my first patch. It's against the current CVS code.
Fixups:
- I updated the HTML output to be a little easier on the eyes. This
still could use a bunch more work, but it's significantly better
(subjectively to me) than it was. Various changes ranging from
font/color/table formatting to removing the "section begin" and "section
end" outputs, since the HTML table clearly delineates the service
beginnings and ends.
- The case of HTML output with splithost on and multiemail off was
broken; The "Reporting on hosts:" line would be emitted before the MIME
type and the HTML, completely breaking some HTML renderers. I moved the
output of that to go under the "Logwatch summary" section.
- In the case of splithost on and multiemail off, the hostname used
for the summary was not the host that logwatch was run on; it would pick
up one of the hosts for which it processed logfiles and use that. Fixed
the email subject to use ${hostname} instead of $config{'hostname'}
which was subject to change.
Still broken:
Splithost on and multiemail off is badly broken. In the case of HTML
format, the html header and footer will be emitted at the beginning and
end of each host. The copyright/legal notice will be appended
repeatedly to a variable which is emitted at the end of each host. The
section index accumulates with each successive host, and re-emitted at
the beginning of each host section, with each successive index having
the links for all the previous hosts as well as the current one.
Most of these are probably pretty easy to fix. I'm guessing that nobody
ever tested this combination. It's not what I intend to use in the long
term, but it would be good to get it basically working; would probably
mean the code was a bit cleaner ;)
Some other issues with HTML output in general-
At some point in every run through logs I've tried, the output
function breaks- it starts treating calls where the type sent is "line"
as "header" type. Not sure what's going on there, but it buggers up the
tail ends of all my HTML logwatch reports.
Several of the scripts emit blank lines, which turn into empty table
cells. Annoying, but only a cosmetic nitpick.
Lastly, I'm having difficulty determining the appropriate way to set up
a central loghost. From a syslog standpoint, it was easy. I configured
syslog-ng to log everything from local stuff normally, but if things
came in from the network, they are punted to
/var/log/hosts/HOSTNAME.log.
For switches, that works fine, because I can associate the log for each
switch to it's logfile group pertaining to the service. For hosts where
I want to run multiple services against a single logfile, I haven't yet
figured out if it's possible to make it work. If someone could confirm
that logwatch doesn't do this, or tell me I'm an idiot and I need to
RTFM again, I'd much appreciate it.
Cheers
Ross
_______________________________________________
Logwatch-Devel mailing list
[email protected]
http://www2.list.logwatch.org:81/mailman/listinfo/logwatch-devel
logwatch.cvs.patch
(application/octet-stream, 6 KB)
diff -ur logwatch.orig/conf/html/header.html logwatch/conf/html/header.html
--- logwatch.orig/conf/html/header.html 2006-09-26 10:39:59.000000000 -0700
+++ logwatch/conf/html/header.html 2007-09-17 00:12:03.000000000 -0700
@@ -4,17 +4,21 @@
<title>Logwatch $Version ( $VDate )</title>
<meta name="generator" content="Logwatch $Version ( $VDate )">
<style type="text/css">
- h1 {color: gray; border-bottom: 3px double silver}
- h2,h3 {color: gray; border-bottom: 1px solid silver}
- .ref {padding-left: 1%}
- .service {padding-left: 1%; font-family: Monospace}
+ h1 {color: gray; border-bottom: 3px double silver; font-family: sans-serif; }
+ h2 {color: white; border-bottom: 1px solid silver; font-family: sans-serif; }
+ h3 {color: white; border-bottom: 1px solid silver; font-family: sans-serif; }
+ th {background: #6D88AD; text-align: left; font-family: sans-serif; }
+ td {background: #EFEFEF; text-align: left; font-family: courier,serif; font-size: 10px; }
+ li { font-family: sans-serif; }
+ .ref {padding-left: 1%; }
+ .service {padding-left: 1%; }
.return_link {border-top: 1px; border-bottom: 1px;
- padding: 1%; margin-top: 1%; margin-bottom: 1%;}
+ padding: 1%; margin-top: 1%; margin-bottom: 1%; font-family: sans-serif; }
.copyright {color: black; border-top: 1px solid grey;
border-bottom: 1px solid grey;
padding: 1%; margin-top: 1%; margin-bottom: 1%;}
</style>
</head>
-<body style="width:90%; margin-left: 5%; margin-right: 5%" bgcolor="#FFFFFF">
+<body style="width:90%; margin-left: 5%; margin-right: 5%" bgcolor="#FFFFFF" >
<hr>
<!-- End header.html -->
diff -ur logwatch.orig/scripts/logwatch.pl logwatch/scripts/logwatch.pl
--- logwatch.orig/scripts/logwatch.pl 2007-09-01 18:14:01.000000000 -0700
+++ logwatch/scripts/logwatch.pl 2007-09-17 00:17:23.000000000 -0700
@@ -1029,7 +1029,7 @@
print OUTFILE "To: $to\n";
}
print OUTFILE "From: $Config{'mailfrom'}\n";
- print OUTFILE "Subject: Logwatch for $Config{'hostname'} (${OStitle})\n";
+ print OUTFILE "Subject: Logwatch for ${hostname} (${OStitle})\n";
#Add MIME
$out_mime = "MIME-Version: 1.0\n";
#Config{encode} switch
@@ -1045,9 +1045,6 @@
$out_mime .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n\n";
}
- if (($Config{'splithosts'} eq 1) && ($Config{'multiemail'} eq 0)) {
- print OUTFILE "Reporting on hosts: @hosts\n";
- }
$emailopen = 'y';
} #End if multiemail || emailopen
} #End if printing/save/else
@@ -1073,7 +1070,7 @@
$index_par++;
if ( $Config{'format'} eq "html" ) {
output( $index_par, "LOGWATCH Summary" . (($Config{'splithosts'} eq 1) ? ": $Config{'hostname'}" : ""), "start");
- output( $index_par, "\n <h2><font color=\"blue\"> Logwatch $Version ($VDate)</font></h2>\n", "header");
+ output( $index_par, " Logwatch Version: $Version ($VDate)\n", "line");
} else {
output( $index_par, "\n ################### Logwatch $Version ($VDate) #################### \n", "line");
}
@@ -1087,6 +1084,9 @@
output( $index_par, " Detail Level of Output: $Config{'detail'}\n", "line");
output( $index_par, " Type of Output/Format: $Config{'output'} / $Config{'format'}\n", "line");
output( $index_par, " Logfiles for Host: $Config{'hostname'}\n", "line");
+ if (($Config{'splithosts'} eq 1) && ($Config{'multiemail'} eq 0)) {
+ output( $index_par, " Reporting on hosts: @hosts\n","line");
+ }
if ( $Config{'format'} eq "html" ) {
output( $index_par, "\n", "stop");
@@ -1222,7 +1222,7 @@
}
if ( $Config{'format'} eq "html" ) {
#BODY <!-- SERVICE START -->
- output( $index_par, "\n <h3><font color=\"blue\">$ServiceData{$Service}{'title'} $BeginVar </font></h3>\n", "header");
+# output( $index_par, "\n <h2>$ServiceData{$Service}{'title'}</h2>\n", "header");
} else {
output( $index_par, "\n --------------------- $ServiceData{$Service}{'title'} $BeginVar ------------------------ \n\n", "line");
}
@@ -1235,7 +1235,7 @@
if ($has_output and $ServiceData{$Service}{'title'}) {
if ( $Config{'format'} eq "html" ) {
if ($Ignored > 0) { output( $index_par, "\n $Ignored Ignored Lines\n", "header"); };
- output( $index_par, "\n <h3><font color=\"blue\">$ServiceData{$Service}{'title'} End </font></h3>\n", "header");
+# output( $index_par, "\n <h3><font color=\"blue\">$ServiceData{$Service}{'title'} End </font></h3>\n", "header");
} else {
if ($Ignored > 0) { output( $index_par, "\n $Ignored Ignored Lines\n", "line"); };
output( $index_par, "\n ---------------------- $ServiceData{$Service}{'title'} End ------------------------- \n\n", "line");
@@ -1286,7 +1286,7 @@
if ( $Config{'format'} eq "html" ) {
$index_par++;
output( $index_par, "Logwatch End", "start" );
- output( $index_par, "\n <h3><font color=\"blue\">Logwatch ended at ". localtime(time) ."</font></h3>\n", "header") if ($printing);
+ output( $index_par, "<h3>Logwatch ended at ". localtime(time) ."</h3>", "line") if ($printing);
output( $index_par, "\n", "stop");
} else {
output( $index_par, $report_finish, "line") if ($printing);
@@ -1359,10 +1359,12 @@
$reports[$index] = "$text";
#SERVICE table headers if ( $index eq 'E' ) { #never happens change out_body from hash back to array
if ( $Config{'format'} eq "html" ) {
- $out_body{$index} .= " <hr>
- <h2><a name=\"$index\">$reports[$index]</a></h2>
- <div class=service>
- <table border=1 width=100%>\n";
+ $out_body{$index} .=
+ "<div class=service>
+ <table border=1 width=100%>
+ <tr><th>
+ <h2><a name=\"$index\">$reports[$index]</a></h2>
+ </tr></th>\n";
}
}