3
3
##########################################################################
4
# $Id: logwatch.pl,v 1.192 2007/05/20 00:24:20 kirk Exp $
4
# $Id: logwatch.pl,v 1.211 2008/05/09 01:05:29 mike Exp $
5
5
##########################################################################
6
6
# Most current version can always be found at:
7
# ftp://ftp.logwatch.org/pub/redhat/RPMS
7
# ftp://ftp.logwatch.org/pub/linux (tarball)
8
# ftp://ftp.logwatch.org/pub/redhat/RPMS (RPMs)
9
10
########################################################
10
11
# Specify version and build-date:
11
my $Version = '7.3.6';
12
my $VDate = '05/19/07';
12
my $Version = '7.3.6+cvs20080702-debian';
13
my $VDate = '07/02/08';
14
15
#######################################################
15
# This was written and is maintained by:
16
# Logwatch was written and is maintained by:
16
17
# Kirk Bauer <kirk@kaybee.org>
19
# Unless otherwise specified, Logwatch and all bundled filter scripts
20
# are Copyright (c) Kirk Bauer and covered under the included MIT/X
18
23
# Please send all comments, suggestions, bug reports,
19
24
# etc, to logwatch@logwatch.org.
21
26
########################################################
28
############################################################################
23
30
# About the locale: some functions use locale information. In particular,
24
31
# Logwatch makes use of strftime, which makes use of LC_TIME variable. Other
25
32
# functions may also use locale information.
105
120
my ($OSname, $hostname, $release, $version, $machine) = POSIX::uname();
106
121
$Config{'hostname'} = "$hostname";
108
#############################################################################
111
# Show usage for this program
112
print "\nUsage: $0 [--detail <level>] [--logfile <name>]\n" .
113
" [--print] [--mailto <addr>] [--archives] [--range <range>] [--debug <level>]\n" .
114
" [--save <filename>] [--help] [--version] [--service <name>]\n" .
115
" [--numeric] [--output <output_type>]\n" .
116
" [--splithosts] [--multiemail]\n\n";
117
print "--detail <level>: Report Detail Level - High, Med, Low or any #.\n";
118
print "--logfile <name>: *Name of a logfile definition to report on.\n";
119
print "--logdir <name>: Name of default directory where logs are stored.\n";
120
print "--service <name>: *Name of a service definition to report on.\n";
121
print "--print: Display report to stdout.\n";
122
print "--mailto <addr>: Mail report to <addr>.\n";
123
print "--archives: Use archived log files too.\n";
124
print "--save <filename>: Save to <filename>.\n";
125
print "--range <range>: Date range: Yesterday, Today, All, Help\n";
126
print " where help will describe additional options\n";
127
print "--numeric: Display addresses numerically rather than symbolically and numerically\n";
128
print " (saves a nameserver address-to-name lookup).\n";
129
print "--debug <level>: Debug Level - High, Med, Low or any #.\n";
130
# hostname needs to be cleaned up and explained
131
# print "--hostname <host>:
132
print "--splithosts: Create a report for each host in syslog.\n";
133
print "--multiemail: Send each host report in a separate email. Ignored if \n";
134
print " not using --splithosts.\n";
135
print "--output <output type>: Report Format - mail, html or unformatted#.\n";
136
print "--encode: Use base64 encoding on output mail.\n";
137
print "--version: Displays current version.\n";
138
print "--help: This message.\n";
139
print "* = Switch can be specified multiple times...\n\n";
143
123
my %wordsToInts = (yes => 1, no => 0,
144
124
true => 1, false => 0,
145
125
on => 1, off => 0,
147
127
med => 5, medium => 5,
152
my $tmpWord = lc $word;
154
return $wordsToInts{$tmpWord} if (defined $wordsToInts{$tmpWord});
155
unless ($word =~ s/^"(.*)"$/$1/) {
162
foreach (keys %Config) {
163
$Config{$_} = getInt($Config{$_});
167
sub PrintStdArray (@) {
170
for ($i=0;$i<=$#ThisArray;$i++) {
171
print "[" . $i . "] = " . $ThisArray[$i] . "\n";
176
# for debugging, print out config...
177
foreach (keys %Config) {
178
print $_ . ' -> ' . $Config{$_} . "\n";
180
print "Service List:\n";
181
PrintStdArray @ServiceList;
183
print "LogFile List:\n";
184
PrintStdArray @LogFileList;
189
sub PrintServiceData () {
190
my ($ThisKey1,$ThisKey2,$i);
191
foreach $ThisKey1 (keys %ServiceData) {
192
print "\nService Name: " . $ThisKey1 . "\n";
193
foreach $ThisKey2 (keys %{$ServiceData{$ThisKey1}}) {
194
next unless ($ThisKey2 =~ /^\d+-/);
195
print " $ThisKey2 = $ServiceData{$ThisKey1}{$ThisKey2}\n";
197
for ($i=0;$i<=$#{$ServiceData{$ThisKey1}{'logfiles'}};$i++) {
198
print " Logfile = " . $ServiceData{$ThisKey1}{'logfiles'}[$i] . "\n";
204
sub PrintLogFileData () {
205
my ($ThisKey1,$ThisKey2,$i);
206
foreach $ThisKey1 (keys %LogFileData) {
207
print "\nLogfile Name: " . $ThisKey1 . "\n";
208
foreach $ThisKey2 (keys %{$LogFileData{$ThisKey1}}) {
209
next unless ($ThisKey2 =~ /^\d+-/);
210
print " $ThisKey2 = $LogFileData{$ThisKey1}{$ThisKey2}\n";
212
for ($i=0;$i<=$#{$LogFileData{$ThisKey1}{'logfiles'}};$i++) {
213
print " Logfile = " . $LogFileData{$ThisKey1}{'logfiles'}[$i] . "\n";
215
for ($i=0;$i<=$#{$LogFileData{$ThisKey1}{'archives'}};$i++) {
216
print " Archive = " . $LogFileData{$ThisKey1}{'archives'}[$i] . "\n";
222
my $FileName = $_[0];
225
if ( ! -f $FileName ) {
229
if ($Config{'debug'} > 5) {
230
print "ReadConfigFile: Opening " . $FileName . "\n";
232
open (READCONFFILE, $FileName) or die "Cannot open file $FileName: $!\n";
234
while ($line = <READCONFFILE>) {
235
if ($Config{'debug'} > 9) {
236
print "ReadConfigFile: Read Line: " . $line;
238
$line =~ s/\#.*\\\s*$/\\/;
240
next if ($line =~ /^\s*$/);
243
next if ($line !~ m/\Q$Prefix:\E/);
244
$line =~ s/\Q$Prefix:\E//;
247
if ($line =~ s/\\\s*$//) {
248
$line .= <READCONFFILE>;
249
redo unless eof(READCONFFILE);
252
my ($name, $value) = split /=/, $line, 2;
253
$name =~ s/^\s+//; $name =~ s/\s+$//;
254
if ($value) { $value =~ s/^\s+//; $value =~ s/\s+$//; }
255
else { $value = ''; }
257
push @ReadConfigNames, lc $name;
258
push @ReadConfigValues, getInt $value;
259
if ($Config{'debug'} > 7) {
260
print "ReadConfigFile: Name=" . $name . ", Value=" . $value . "\n";
266
#############################################################################
130
#############################################################################
132
#############################################################################
133
#Load CONFIG, READ OPTIONS, make adjustments
268
135
# Load main config file...
269
136
if ($Config{'debug'} > 8) {
270
137
print "\nDefault Config:\n";
276
143
# For each of the configuration sets (logwatch.conf here, and
277
144
# logfiles,and services later), we do the following:
320
187
my @TempServiceList = ();
322
189
my $ShowVersion = 0;
190
my ($tmp_mailto, $tmp_savefile);
325
GetOptions ( "d|detail=s" => \$Config{'detail'},
192
&GetOptions ("d|detail=s" => \$Config{'detail'},
326
193
"l|logfile=s@" => \@TempLogFileList,
327
194
"logdir=s" => \$Config{'logdir'},
328
195
"s|service=s@" => \@TempServiceList,
329
"p|print" => \$Config{'print'},
330
"m|mailto:s" => \$tmp_mailto,
331
"save=s" => \$Config{'save'},
196
"m|mailto=s" => \$tmp_mailto,
197
"filename=s" => \$tmp_savefile,
332
198
"a|archives" => \$Config{'archives'},
333
199
"debug=s" => \$Config{'debug'},
334
200
"r|range=s" => \$Config{'range'},
335
201
"n|numeric" => \$Config{'numeric'},
336
202
"h|help" => \$Help,
337
204
"v|version" => \$ShowVersion,
338
205
"hostname=s" => \$Config{'hostname'},
339
"splithosts" => \$Config{'splithosts'},
340
"multiemail" => \$Config{'multiemail'},
341
206
"o|output=s" => \$Config{'output'},
342
"encode" => \$Config{'encode'},
343
"html_wrap=s" => \$Config{'html_wrap'}
207
"f|format=s" => \$Config{'format'},
208
"e|encode=s" => \$Config{'encode'},
209
"hostformat=s" => \$Config{'hostformat'},
210
"hostlimit=s" => \$Config{'hostlimit'},
211
"html_wrap=s" => \$Config{'html_wrap'},
212
"subject=s" => \$Config{'subject'}
217
#Catch option exceptions and extra logic here -mgt
348
219
if ($Config{'range'} =~ /help/i) {
798
677
$ENV{'LOGWATCH_DATE_RANGE'} = $Config{'range'};
799
678
$ENV{'LOGWATCH_GLOBAL_DETAIL'} = $Config{'detail'};
800
$ENV{'LOGWATCH_OUTPUT_TYPE'} = $Config{'output'};
679
$ENV{'LOGWATCH_OUTPUT_TYPE'} = $Config{'output'}; #8.0
680
$ENV{'LOGWATCH_FORMAT_TYPE'} = $Config{'format'}; #8.0
801
681
$ENV{'LOGWATCH_DEBUG'} = $Config{'debug'};
802
682
$ENV{'LOGWATCH_TEMP_DIR'} = $TempDir;
803
683
$ENV{'LOGWATCH_NUMERIC'} = $Config{'numeric'};
804
684
$ENV{'HOSTNAME'} = $Config{'hostname'};
805
685
$ENV{'OSname'} = $OSname;
687
#split and splitmail also play with LOGWATCH_ONLY_HOSTNAME which is not shown by debug
807
688
if ($Config{'hostlimit'}) {
808
$ENV{'LOGWATCH_ONLY_HOSTNAME'} = $Config{'hostname'};
809
$ENV{'LOGWATCH_ONLY_HOSTNAME'} =~ s/\..*//;
689
#Pass the list to ENV with out touching it
690
$ENV{'LOGWATCH_ONLY_HOSTNAME'} = $Config{'hostlimit'};
811
693
if ($Config{'debug'}>4) {
812
foreach ('LOGWATCH_DATE_RANGE', 'LOGWATCH_GLOBAL_DETAIL', 'LOGWATCH_OUTPUT_TYPE',
813
'LOGWATCH_TEMP_DIR', 'LOGWATCH_DEBUG', 'LOGWATCH_ONLY_HOSTNAME') {
694
foreach ('LOGWATCH_DATE_RANGE', 'LOGWATCH_GLOBAL_DETAIL', 'LOGWATCH_OUTPUT_TYPE',
695
'LOGWATCH_FORMAT_TYPE', 'LOGWATCH_TEMP_DIR', 'LOGWATCH_DEBUG', 'LOGWATCH_ONLY_HOSTNAME') {
815
697
print "export $_='$ENV{$_}'\n";
865
747
$CheckTime = $time_t[0] - 86400*2;
750
print STDERR "ERROR: Range \'$Config{'range'}\' not understood\n";
755
#Archives are cat'd without any filters then cat'd along with the normal log file
871
756
my @FileStat = stat($Archive);
872
757
if ($CheckTime <= ($FileStat[9])) {
873
if (($Archive =~ m/gz$/) && (-f "$Archive")) {
874
#These system calls are not secure but we are getting closer
875
#What needs to go is all the pipes and instead we need a command loop
876
#For each filter to apply -mgt
758
if (($Archive =~ m/gz$/) && (-f "$Archive") && (-s "$Archive")) {
877
759
my $arguments = "$Archive >> $DestFile";
878
760
system("$Config{'pathtozcat'} $arguments") == 0
879
or die "system $Config{'pathtozcat'} failed: $?"
880
} elsif (($Archive =~ m/bz2$/) && (-f "$Archive")) {
881
#These system calls are not secure but we are getting closer
882
#What needs to go is all the pipes and instead we need a command loop
883
#For each filter to apply -mgt
761
or die "system '$Config{'pathtozcat'} $arguments' failed: $?"
762
} elsif (($Archive =~ m/bz2$/) && (-f "$Archive") && (-s "$Archive")) {
884
763
my $arguments = "$Archive 2>/dev/null >> $DestFile";
885
764
system("$Config{'pathtobzcat'} $arguments") == 0
886
or die "system $Config{'pathtobzcat'} failed: $?"
887
} elsif (-f "$Archive") {
765
or die "system '$Config{'pathtobzcat'} $arguments' failed: $?"
766
} elsif ((-f "$Archive") && (-s "$Archive")) {
888
767
my $arguments = "$Archive >> $DestFile";
889
768
system("$Config{'pathtocat'} $arguments") == 0
890
or die "system $Config{'pathtocat'} failed: $?"
769
or die "system '$Config{'pathtocat'} $arguments' failed: $?"
891
770
} #End if/elsif existence
892
771
} #End if $CheckTime
961
849
if ($LogFile !~ /^[-_\w\d]+$/) {
962
850
print STDERR "Unexpected filename: [[$LogFile]]. Not used\n"
964
#These system calls are not secure but we are getting closer
965
#What needs to go is all the pipes and instead we need a command loop
966
#For each filter to apply -mgt
852
#System call does the log processing
967
853
system("$Config{'pathtocat'} $Command") == 0
968
or die "system $Config{'pathtocat'} $Command failed: $?"
854
or die "system '$Config{'pathtocat'} $Command' failed: $?"
973
859
#populate the host lists if we're splitting hosts
860
#It seems this is run after the file is parsed so it is done 2 times?
861
#Can it be put inline with the above filters?
975
if ($Config{'splithosts'} eq 1) {
863
if ($Config{'hostformat'} ne "none") { #8.0
978
866
opendir (LOGDIR,$TempDir) || die "Cannot open dir";
979
867
@logarray = readdir(LOGDIR);
980
868
closedir (LOGDIR);
981
869
my $ecpcmd = ("| $PerlVersion $BaseDir/scripts/shared/hostlist");
870
#Note hostlist and hosthash [which is never used] exist to build list of host names seen
982
871
foreach $newlogfile (@logarray) {
983
872
my $eeefile = ("$TempDir" . "$newlogfile");
984
873
if ((!(-d $eeefile)) && (!($eeefile =~ m/-archive/))) {
985
874
system("$Config{'pathtocat'} $eeefile $ecpcmd") == 0
986
or die "system $Config{'pathtocat'} $eeefile $ecpcmd failed: $?"
875
or die "system '$Config{'pathtocat'} $eeefile $ecpcmd' failed: $?"
989
878
#read in the final host list
1000
890
my $printing = '';
1001
891
my $emailopen = '';
893
####################################################################
896
if ($Config{'hostformat'} ne "none") {
898
foreach $Host (@hosts) {
900
$ENV{'LOGWATCH_ONLY_HOSTNAME'} = $Host;
901
$Config{'hostname'} = $Host; #resetting hostname here makes it appear in output header -mgt
908
#Close Filehandle is needed -mgt
909
close(OUTFILE) unless ($Config{'output'} eq "stdout");
910
#############################################################################
914
#############################################################################
916
#############################################################################
918
######################################################################
920
#Notes: Called by CleanVars
921
######################################################################
924
unless (defined($word)) { return $word; }
925
my $tmpWord = lc $word;
927
return $wordsToInts{$tmpWord} if (defined $wordsToInts{$tmpWord});
928
unless ($word =~ s/^"(.*)"$/$1/) {
934
######################################################################
936
#Notes: Called during #Load CONFIG, READ OPTIONS, make adjustments
937
######################################################################
939
foreach (keys %Config) {
940
$Config{$_} = getInt($Config{$_});
944
######################################################################
947
######################################################################
948
sub PrintStdArray (@) {
951
for ($i=0;$i<=$#ThisArray;$i++) {
952
print "[" . $i . "] = " . $ThisArray[$i] . "\n";
956
######################################################################
959
######################################################################
961
# for debugging, print out config...
962
foreach (keys %Config) {
963
print $_ . ' -> ' . $Config{$_} . "\n";
965
print "Service List:\n";
966
&PrintStdArray(@ServiceList);
968
print "LogFile List:\n";
969
&PrintStdArray(@LogFileList);
973
######################################################################
974
#sub PrintServiceData
976
######################################################################
978
sub PrintServiceData () {
979
my ($ThisKey1,$ThisKey2,$i);
980
foreach $ThisKey1 (keys %ServiceData) {
981
print "\nService Name: " . $ThisKey1 . "\n";
982
foreach $ThisKey2 (keys %{$ServiceData{$ThisKey1}}) {
983
next unless ($ThisKey2 =~ /^\d+-/);
984
print " $ThisKey2 = $ServiceData{$ThisKey1}{$ThisKey2}\n";
986
for ($i=0;$i<=$#{$ServiceData{$ThisKey1}{'logfiles'}};$i++) {
987
print " Logfile = " . $ServiceData{$ThisKey1}{'logfiles'}[$i] . "\n";
992
######################################################################
993
#sub PrintLogFileData
995
######################################################################
997
sub PrintLogFileData () {
998
my ($ThisKey1,$ThisKey2,$i);
999
foreach $ThisKey1 (keys %LogFileData) {
1000
print "\nLogfile Name: " . $ThisKey1 . "\n";
1001
foreach $ThisKey2 (keys %{$LogFileData{$ThisKey1}}) {
1002
next unless ($ThisKey2 =~ /^\d+-/);
1003
print " $ThisKey2 = $LogFileData{$ThisKey1}{$ThisKey2}\n";
1005
for ($i=0;$i<=$#{$LogFileData{$ThisKey1}{'logfiles'}};$i++) {
1006
print " Logfile = " . $LogFileData{$ThisKey1}{'logfiles'}[$i] . "\n";
1008
for ($i=0;$i<=$#{$LogFileData{$ThisKey1}{'archives'}};$i++) {
1009
print " Archive = " . $LogFileData{$ThisKey1}{'archives'}[$i] . "\n";
1011
if ($LogFileData{$ThisKey1}{'nohostfilter'}) {
1012
print " NoHostFilter = " . $LogFileData{$ThisKey1}{'nohostfilter'} . "\n";
1017
######################################################################
1020
######################################################################
1021
sub ReadConfigFile {
1022
my $FileName = $_[0];
1025
if ( ! -f $FileName ) {
1029
if ($Config{'debug'} > 5) {
1030
print "ReadConfigFile: Opening " . $FileName . "\n";
1032
open (READCONFFILE, $FileName) or die "Cannot open file $FileName: $!\n";
1034
while ($line = <READCONFFILE>) {
1035
if ($Config{'debug'} > 9) {
1036
print "ReadConfigFile: Read Line: " . $line;
1038
$line =~ s/\#.*\\\s*$/\\/;
1040
next if ($line =~ /^\s*$/);
1043
next if ($line !~ m/\Q$Prefix:\E/);
1044
$line =~ s/\Q$Prefix:\E//;
1047
if ($line =~ s/\\\s*$//) {
1048
$line .= <READCONFFILE>;
1049
redo unless eof(READCONFFILE);
1052
my ($name, $value) = split /=/, $line, 2;
1053
$name =~ s/^\s+//; $name =~ s/\s+$//;
1054
if ($value) { $value =~ s/^\s+//; $value =~ s/\s+$//; }
1055
else { $value = ''; }
1057
push @ReadConfigNames, lc $name;
1058
push @ReadConfigValues, getInt $value;
1059
if ($Config{'debug'} > 7) {
1060
print "ReadConfigFile: Name=" . $name . ", Value=" . $value . "\n";
1066
#########################################################################
1069
#########################################################################
1071
# Show usage for this program
1072
print "\nUsage: $0 [--detail <level>] [--logfile <name>] [--output <output_type>]\n" .
1073
" [--format <format_type>] [--encode <enconding>] [--numeric]\n" .
1074
" [--mailto <addr>] [--archives] [--range <range>] [--debug <level>]\n" .
1075
" [--filename <filename>] [--help|--usage] [--version] [--service <name>]\n" .
1076
" [--hostformat <host_format type>] [--hostlimit <host1,host2>] [--html_wrap <num_characters>]\n\n";
1077
print "--detail <level>: Report Detail Level - High, Med, Low or any #.\n";
1078
print "--logfile <name>: *Name of a logfile definition to report on.\n";
1079
print "--logdir <name>: Name of default directory where logs are stored.\n";
1080
print "--service <name>: *Name of a service definition to report on.\n";
1081
print "--output <output type>: Report Output - stdout [default], mail, file.\n"; #8.0
1082
print "--format <formatting>: Report Format - text [default], html.\n"; #8.0
1083
print "--encode <encoding>: Enconding to use - none [default], base64.\n"; #8.0
1084
print "--mailto <addr>: Mail report to <addr>.\n";
1085
print "--archives: Use archived log files too.\n";
1086
print "--filename <filename>: Used to specify they filename to save to. --filename <filename> [Forces output to file].\n";
1087
print "--range <range>: Date range: Yesterday, Today, All, Help\n";
1088
print " where help will describe additional options\n";
1089
print "--numeric: Display addresses numerically rather than symbolically and numerically\n";
1090
print " (saves a nameserver address-to-name lookup).\n";
1091
print "--debug <level>: Debug Level - High, Med, Low or any #.\n";
1092
print "--hostformat: Host Based Report Options - none [default], split, splitmail.\n"; #8.0
1093
print "--hostlimit: Limit report to hostname - host1,host2.\n"; #8.0
1094
print "--html_wrap <num_characters>: Default is 80.\n";
1095
print "--version: Displays current version.\n";
1096
print "--help: This message.\n";
1097
print "--usage: Same as --help.\n";
1098
print "* = Switch can be specified multiple times...\n\n";
1101
############################################################################
1103
#############################################################################
1105
#############################################################################
1108
#############################################################################
1003
1109
sub initprint {
1004
1110
return if $printing;
1023
1130
print OUTFILE "To: $to\n";
1025
1132
print OUTFILE "From: $Config{'mailfrom'}\n";
1026
print OUTFILE "Subject: Logwatch for $Config{'hostname'} (${OStitle})\n";
1133
#If $Config{'subject'} exists lets use it.
1134
#This does not allow for variable expansion as the default below does -mgt
1135
if ($Config{'subject'}) {
1136
print OUTFILE "Subject: $Config{'subject'}\n";
1138
print OUTFILE "Subject: Logwatch for $Config{'hostname'} (${OStitle})\n";
1028
1141
$out_mime = "MIME-Version: 1.0\n";
1029
if ( $Config{encode} == 1 ) {
1142
#Config{encode} switch
1143
if ( $Config{'encode'} eq "base64" ) {
1030
1144
$out_mime .= "Content-transfer-encoding: base64\n";
1032
1146
$out_mime .= "Content-Transfer-Encoding: 7bit\n";
1034
if ( $outtype_html ) {
1148
#Config{output} html
1149
if ( $Config{'format'} eq "html" ) {
1035
1150
$out_mime .= "Content-Type: text/html; charset=\"iso-8859-1\"\n\n";
1037
1152
$out_mime .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n\n";
1040
if (($Config{'splithosts'} eq 1) && ($Config{'multiemail'} eq 0)) {
1155
if ($Config{'hostformat'} eq "split") { #8.0 check hostlimit also? or ne none?
1041
1156
print OUTFILE "Reporting on hosts: @hosts\n";
1043
1158
$emailopen = 'y';
1044
} #End if multiemail || emailopen
1159
} #End if hostformat || emailopen
1045
1160
} #End if printing/save/else
1046
1161
$printing = 'y';
1048
1163
# simple parse of the dates
1049
my $simple_timematch = TimeFilter(" %Y-%b-%d %Hh %Mm %Ss ");
1164
my $simple_timematch = &TimeFilter(" %Y-%b-%d %Hh %Mm %Ss ");
1050
1165
my @simple_range = split(/\|/, $simple_timematch);
1051
1166
if ($#simple_range > 1) {
1052
1167
# delete all array entries, except first and last
1063
1178
my $print_range = join("/",@simple_range);
1066
if ( $outtype_html ) {
1067
output( $index_par, "LOGWATCH Summary" . (($Config{'splithosts'} eq 1) ? ": $Config{'hostname'}" : ""), "start");
1068
output( $index_par, "\n <h2><font color=\"blue\"> Logwatch $Version ($VDate)</font></h2>\n", "header");
1181
if ( $Config{'format'} eq "html" ) {
1182
&output( $index_par, "LOGWATCH Summary" . (($Config{'hostformat'} ne "none") ? ": $Config{'hostname'}" : ""), "start");
1183
&output( $index_par, " Logwatch Version: $Version ($VDate)\n", "line");
1070
output( $index_par, "\n ################### Logwatch $Version ($VDate) #################### \n", "line");
1185
&output( $index_par, "\n ################### Logwatch $Version ($VDate) #################### \n", "line");
1073
output( $index_par, " Processing Initiated: " . localtime(time) . "\n", "line");
1074
output( $index_par, " Date Range Processed: $Config{'range'}\n", "line");
1075
output( $index_par, " $print_range\n", "line") if ($Config{'range'} ne 'all');
1076
output( $index_par, " Period is " . GetPeriod() . ".\n", "line")
1077
if ($Config{'range'} ne 'all');
1078
output( $index_par, " Detail Level of Output: $Config{'detail'}\n", "line");
1079
output( $index_par, " Type of Output: $Config{'output'}\n", "line");
1080
output( $index_par, " Logfiles for Host: $Config{'hostname'}\n", "line");
1188
&output( $index_par, " Processing Initiated: " . localtime(time) . "\n", "line");
1189
&output( $index_par, " Date Range Processed: $Config{'range'}\n", "line");
1190
&output( $index_par, " $print_range\n", "line")
1191
if ($Config{'range'} ne 'all');
1192
&output( $index_par, " Period is " . &GetPeriod() . ".\n", "line")
1193
if ($Config{'range'} ne 'all');
1194
&output( $index_par, " Detail Level of Output: $Config{'detail'}\n", "line");
1195
&output( $index_par, " Type of Output/Format: $Config{'output'} / $Config{'format'}\n", "line");
1196
&output( $index_par, " Logfiles for Host: $Config{'hostname'}\n", "line");
1082
if ( $outtype_html ) {
1083
output( $index_par, "\n", "stop");
1198
if ( $Config{'format'} eq "html" ) {
1199
&output( $index_par, "\n", "stop");
1085
output( $index_par, " ################################################################## \n", "line");
1201
&output( $index_par, " ################################################################## \n", "line");
1205
####################################################################
1207
####################################################################
1209
###################################################################
1212
###################################################################
1090
1213
sub parselogs {
1205
1332
if (($has_output == 0) and ($ServiceData{$Service}{'title'})) {
1207
output($index_par, $ServiceData{$Service}{'title'}, "start" );
1334
&output($index_par, $ServiceData{$Service}{'title'}, "start" );
1209
1336
if ($ENV{'LOGWATCH_GLOBAL_DETAIL'} == $ENV{'LOGWATCH_DETAIL_LEVEL'}) {
1210
1337
$BeginVar = "Begin";
1212
1339
$BeginVar = "Begin (detail=" . $ENV{'LOGWATCH_DETAIL_LEVEL'} . ")";
1214
if ( $outtype_html ) {
1341
if ( $Config{'format'} eq "html" ) {
1215
1342
#BODY <!-- SERVICE START -->
1216
output( $index_par, "\n <h3><font color=\"blue\">$ServiceData{$Service}{'title'} $BeginVar </font></h3>\n", "header");
1343
#&output( $index_par, "\n <h2>$ServiceData{$Service}{'title'}</h2>\n", "header");
1218
output( $index_par, "\n --------------------- $ServiceData{$Service}{'title'} $BeginVar ------------------------ \n\n", "line");
1345
&output( $index_par, "\n --------------------- $ServiceData{$Service}{'title'} $BeginVar ------------------------ \n\n", "line");
1220
1347
$has_output = 1;
1222
output( $index_par, $ThisLine, "line");
1349
&output( $index_par, $ThisLine, "line");
1224
1351
close (TESTFILE);
1226
1353
if ($has_output and $ServiceData{$Service}{'title'}) {
1227
if ( $outtype_html ) {
1228
if ($Ignored > 0) { output( $index_par, "\n $Ignored Ignored Lines\n", "header"); };
1229
output( $index_par, "\n <h3><font color=\"blue\">$ServiceData{$Service}{'title'} End </font></h3>\n", "header");
1354
if ( $Config{'format'} eq "html" ) {
1355
if ($Ignored > 0) { &output( $index_par, "\n $Ignored Ignored Lines\n", "header"); };
1356
#&output( $index_par, "\n <h3><font color=\"blue\">$ServiceData{$Service}{'title'} End </font></h3>\n", "header");
1231
if ($Ignored > 0) { output( $index_par, "\n $Ignored Ignored Lines\n", "line"); };
1232
output( $index_par, "\n ---------------------- $ServiceData{$Service}{'title'} End ------------------------- \n\n", "line");
1358
if ($Ignored > 0) { &output( $index_par, "\n $Ignored Ignored Lines\n", "line"); };
1359
&output( $index_par, "\n ---------------------- $ServiceData{$Service}{'title'} End ------------------------- \n\n", "line");
1234
output( $index_par, "\n", "stop");
1361
&output( $index_par, "\n", "stop");
1239
1366
#HTML should be external to logwatch.pl -mgt
1240
1367
#These are steps only needed for HTML output
1241
if ( $outtype_html ) {
1368
if ( $Config{'format'} eq "html" ) {
1243
1370
#Setup temp Variables to swap
1268
1395
#Set up out_reference
1269
output("ul","<a name=top><ul>", "ref_extra") if defined( $index_par );
1396
&output("ul","<a name=top><ul>", "ref_extra") if defined( $index_par );
1270
1397
foreach ( 0 .. $index_par ) {
1271
output($_,$reports[$_], "ref") if defined( $reports[$_] );
1398
&output($_,$reports[$_], "ref") if defined( $reports[$_] );
1273
output("ul","</ul></a>", "ref_extra") if defined( $index_par );
1400
&output("ul","</ul></a>", "ref_extra") if defined( $index_par );
1277
if ( $outtype_html ) {
1404
if ( $Config{'format'} eq "html" ) {
1279
output( $index_par, "Logwatch End", "start" );
1280
output( $index_par, "\n <h3><font color=\"blue\">Logwatch ended at ". localtime(time) ."</font></h3>\n", "header") if ($printing);
1281
output( $index_par, "\n", "stop");
1406
&output( $index_par, "Logwatch Ended at " . localtime(time) , "start" );
1407
&output( $index_par, "\n", "stop");
1283
output( $index_par, $report_finish, "line") if ($printing);
1409
&output( $index_par, $report_finish, "line") if ($printing);
1286
1412
#Printing starts here $out_mime $out_head $out_reference $out_body $out_foot
1287
1413
print OUTFILE $out_mime if $out_mime;
1288
if ( $Config{'encode'} == 1 ) {
1414
if ( $Config{'encode'} eq "base64" ) {
1289
1415
print OUTFILE encode_base64($out_head) if $out_head;
1290
1416
print OUTFILE encode_base64($out_reference) if $out_reference;
1291
1417
foreach ( 0 .. $index_par ) {
1292
1418
print OUTFILE encode_base64($out_body{$_}) if defined( $out_body{$_} );
1293
1420
$out_body{$_} = ''; #We should track this down out_body could be an array instead also -mgt
1295
1422
print OUTFILE encode_base64($out_foot) if $out_foot;