Updated Logwatch 'SearchDate' custom script. Renamed it.

Updated notes in LogFile config.
This commit is contained in:
Asif Bacchus 2018-09-26 22:54:14 -06:00
parent 9ba6b40904
commit 47acc2684c
2 changed files with 10 additions and 5 deletions

View File

@ -4,6 +4,8 @@ LogFile = /path/to/your/cfddns.log
# extension preservation # extension preservation
Archive = /path/to/your/logfile.ext.?.gz Archive = /path/to/your/logfile.ext.?.gz
# Apply the correct date/time filtering to match the format of the script's log # Apply the correct date/time filtering to match the format of the script's log
# We are using a custom pl script in /etc/logwatch/scripts/shared/
# You don't need to change this unless you have altered the 'stamp' variable in # You don't need to change this unless you have altered the 'stamp' variable in
# the script # the script in which case you will want to update the regex in the custom pl
*applystddate = "%Y-%m-%d %H:%M:%S" # script below
*sqFullStampAnywhere

View File

@ -5,14 +5,16 @@
########################################################################## ##########################################################################
############################################################################### ###############################################################################
## Filter dates in full-date-time international format ## Filter dates in full-date-time international format, surrounded by square
## Format: '%Y-%m-%d %H:%M:%S' ## brackets located anywhere on a given line
## Format: '[%Y-%m-%d %H:%M:%S]'
############################################################################### ###############################################################################
use Logwatch ':dates'; use Logwatch ':dates';
my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0; my $Debug = $ENV{'LOGWATCH_DEBUG'} || 0;
### Specify the format of the date/time stamp itself
$SearchDate = TimeFilter('%Y-%m-%d %H:%M:%S'); $SearchDate = TimeFilter('%Y-%m-%d %H:%M:%S');
if ( $Debug > 5 ) { if ( $Debug > 5 ) {
@ -21,7 +23,8 @@ if ( $Debug > 5 ) {
} }
while (defined($ThisLine = <STDIN>)) { while (defined($ThisLine = <STDIN>)) {
if ($ThisLine =~ m/^$SearchDate /o) { ### specify the regex that defines how to find 'SearchDate'
if ($ThisLine =~ m/\[$SearchDate\] /o) {
print $ThisLine; print $ThisLine;
} }
} }