Blame HOWTO-Customize-LogWatch

Packit Bot ea69bd
HOWTO-Customize-LogWatch
Packit Bot ea69bd
================================================================================
Packit Bot ea69bd
Packit Bot ea69bd
1. Table of Contents
Packit Bot ea69bd
====================
Packit Bot ea69bd
Packit Bot ea69bd
  1. Table of Contents
Packit Bot ea69bd
  2. Introduction
Packit Bot ea69bd
  3. Directory Structure
Packit Bot ea69bd
    A. Configuration Structure
Packit Bot ea69bd
    B. Executable Structure
Packit Bot ea69bd
  4. Customizing the Configuration
Packit Bot ea69bd
  5. Customizing the Scripts
Packit Bot ea69bd
  6. Creating New Service Filters
Packit Bot ea69bd
    A. Logfile Groups
Packit Bot ea69bd
    B. Service Filter Configuration
Packit Bot ea69bd
    C. Service Filer Executable
Packit Bot ea69bd
    D. Shared Script Commands
Packit Bot ea69bd
    E. Environment Information
Packit Bot ea69bd
  7. For More Information
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
This document describes the structure of the Logwatch files in the
Packit Bot ea69bd
distribution, how to modify the configuration files for your
Packit Bot ea69bd
system, and how to create new service filters.
Packit Bot ea69bd
Packit Bot ea69bd
2. Introduction
Packit Bot ea69bd
===============
Packit Bot ea69bd
Packit Bot ea69bd
Logwatch is a system log analyzer and reporter.  Usage information
Packit Bot ea69bd
about Logwatch can be obtained through the man page:
Packit Bot ea69bd
	man logwatch
Packit Bot ea69bd
Packit Bot ea69bd
The section titled "MORE INFORMATION" in the man page lists
Packit Bot ea69bd
additional documentation files available with the distribution.
Packit Bot ea69bd
Packit Bot ea69bd
A summary of the command-line switches described in the man page
Packit Bot ea69bd
can be obtained with the '--help' option:
Packit Bot ea69bd
	logwatch --help
Packit Bot ea69bd
Packit Bot ea69bd
The rest of this document is intended for those that wish to
Packit Bot ea69bd
customize or enhance Logwatch beyond the capabilities provided
Packit Bot ea69bd
with the command-line switches.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
3. Directory Structure
Packit Bot ea69bd
======================
Packit Bot ea69bd
Packit Bot ea69bd
This section describes the subdirectories and files shipped
Packit Bot ea69bd
with the Logwatch distribution, using the names and locations
Packit Bot ea69bd
used by default.
Packit Bot ea69bd
Packit Bot ea69bd
The directory /usr/share/logwatch contains both the configuration
Packit Bot ea69bd
and (perl) executable files.  The contents of this directory are
Packit Bot ea69bd
the following subdirectories:
Packit Bot ea69bd
Packit Bot ea69bd
	default.conf:	Contains the default configuration files
Packit Bot ea69bd
			shipped with the Logwatch distribution
Packit Bot ea69bd
Packit Bot ea69bd
	dist.conf:	Contains the configuration files shipped
Packit Bot ea69bd
			with your specific Operating Systems
Packit Bot ea69bd
			distribution.
Packit Bot ea69bd
Packit Bot ea69bd
	lib:		Contains perl library files.
Packit Bot ea69bd
Packit Bot ea69bd
	scripts:	Contains the perl executables.
Packit Bot ea69bd
Packit Bot ea69bd
The /etc/logwatch directory contains the following subdirectories:
Packit Bot ea69bd
Packit Bot ea69bd
	conf:		Contains the configuration files specific
Packit Bot ea69bd
			to the system.
Packit Bot ea69bd
Packit Bot ea69bd
	scripts:	Contains the executable scripts specific
Packit Bot ea69bd
			to the system.
Packit Bot ea69bd
Packit Bot ea69bd
A. Configuration Structure
Packit Bot ea69bd
--------------------------
Packit Bot ea69bd
Packit Bot ea69bd
The contents of the three directories /usr/share/logwatch/default.conf,
Packit Bot ea69bd
/usr/share/logwatch/dist.conf, and /etc/logwatch/conf, all have the
Packit Bot ea69bd
same structure:
Packit Bot ea69bd
Packit Bot ea69bd
	services:	This subdirectory contains the configuration
Packit Bot ea69bd
			files specific to each service.  Logwatch
Packit Bot ea69bd
			determines which services are available by
Packit Bot ea69bd
			examining the contents of this directory.
Packit Bot ea69bd
			Each service configuration file is named by
Packit Bot ea69bd
			its service name with the ".conf" suffix.
Packit Bot ea69bd
Packit Bot ea69bd
	logfiles:	This subdirectory contains the logfile group
Packit Bot ea69bd
			configuration files.  Each logfile group
Packit Bot ea69bd
			configuration file contains information about
Packit Bot ea69bd
			one or more log files with the same format.
Packit Bot ea69bd
			Several services may use the same logfile
Packit Bot ea69bd
			group configuration file.  Each of these
Packit Bot ea69bd
			configuration files are named by the group
Packit Bot ea69bd
			name with the ".conf" suffix.  Many
Packit Bot ea69bd
			of the group names are taken from the name
Packit Bot ea69bd
			of a system log file (such as messages,
Packit Bot ea69bd
			maillog, secure, etc.), but not always.
Packit Bot ea69bd
Packit Bot ea69bd
	logwatch.conf:	This file contains the defaults for the
Packit Bot ea69bd
			overall execution of Logwatch, and affect all
Packit Bot ea69bd
			of its services.  Many of its parameters can
Packit Bot ea69bd
			be overridden by command-line switches when
Packit Bot ea69bd
			invoking the Logwatch executable, as described
Packit Bot ea69bd
			in the man page for Logwatch.
Packit Bot ea69bd
Packit Bot ea69bd
	ignore.conf:	This file specifies regular expressions that,
Packit Bot ea69bd
			when matched by the output of logwatch, will
Packit Bot ea69bd
			suppress the matching line, regardless of which
Packit Bot ea69bd
			service is being executed.
Packit Bot ea69bd
Packit Bot ea69bd
The /etc/logwatch/conf directory may also contain the file 'override.conf',
Packit Bot ea69bd
which is described in section 4, "Customizing the Configuration."
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
B. Executable Structure
Packit Bot ea69bd
-----------------------
Packit Bot ea69bd
Packit Bot ea69bd
The contents of the two directories /usr/share/logwatch/scripts
Packit Bot ea69bd
and /etc/logwatch/scripts have the same structure:
Packit Bot ea69bd
Packit Bot ea69bd
	services:	This subdirectory contains the executable
Packit Bot ea69bd
			for each service.  Unless otherwise specified
Packit Bot ea69bd
			in the configuration service file (see above),
Packit Bot ea69bd
			the executables are written in the perl language.
Packit Bot ea69bd
Packit Bot ea69bd
	shared:		This subdirectory contains executables that may
Packit Bot ea69bd
			be invoked by more than one configuration service
Packit Bot ea69bd
			file.
Packit Bot ea69bd
Packit Bot ea69bd
	logfiles:	This subdirectory may contain subdirectories with
Packit Bot ea69bd
			logfile group names.  The executables under each of
Packit Bot ea69bd
			these subdirectories are automatically invoked when
Packit Bot ea69bd
			running	a service that uses the corresponding
Packit Bot ea69bd
			logfile group name.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
4. Customizing the Configuration
Packit Bot ea69bd
================================
Packit Bot ea69bd
Packit Bot ea69bd
Logwatch can be, and has been, used on many variants of the Linux and
Packit Bot ea69bd
UNIX systems.  Some distributions that include Logwatch modify the
Packit Bot ea69bd
default configuration to comply with the settings of said
Packit Bot ea69bd
distributions.  Therefore, most people will not need to make any
Packit Bot ea69bd
modifications to Logwatch.
Packit Bot ea69bd
Packit Bot ea69bd
However, Logwatch, starting with version 7.0, implements a mechanism
Packit Bot ea69bd
to allow modifying the local system easier.  These modifications may
Packit Bot ea69bd
be needed either because the configuration of the service that writes
Packit Bot ea69bd
to the system log has been altered from its default, or because the
Packit Bot ea69bd
Logwatch user prefers what is reported or how it is reported by
Packit Bot ea69bd
Logwatch to be different.
Packit Bot ea69bd
Packit Bot ea69bd
You can customize the output of logwatch by modifying variables in the
Packit Bot ea69bd
/etc/logwatch/conf directory.
Packit Bot ea69bd
Packit Bot ea69bd
Default values are specified in the /usr/share/logwatch/default.conf
Packit Bot ea69bd
directory.  Your distribution may have set additional defaults in the
Packit Bot ea69bd
/usr/share/logwatch/dist.conf directory.  All the variables available
Packit Bot ea69bd
are declared in the files under these directories.  You can change the
Packit Bot ea69bd
default values to modify how or what is displayed with logwatch.
Packit Bot ea69bd
Packit Bot ea69bd
One variable available to all services, and which by default is not
Packit Bot ea69bd
specified, is the 'Detail' variable (note that it is not preceded by
Packit Bot ea69bd
a '$' symbol).  Specifying a Detail value will override the global
Packit Bot ea69bd
Detail level, for that service only.
Packit Bot ea69bd
Packit Bot ea69bd
There are two mechanisms for customizing the variables:
Packit Bot ea69bd
Packit Bot ea69bd
1. The /etc/logwatch/conf directory is first searched for files with the
Packit Bot ea69bd
   same name and relative location as the
Packit Bot ea69bd
   /usr/share/logwatch/default.conf directory.  Variables declared in
Packit Bot ea69bd
   these files override the defaults.
Packit Bot ea69bd
Packit Bot ea69bd
   For example, if file /etc/logwatch/conf/services/sendmail.conf has the
Packit Bot ea69bd
   single entry:
Packit Bot ea69bd
        $sendmail_unknownusersthreshold = 5
Packit Bot ea69bd
   then the threshold for unknown users is set to five instead of the
Packit Bot ea69bd
   default of one.  All other parameters are not modified.
Packit Bot ea69bd
Packit Bot ea69bd
   The configuration files have four different types of declarations,
Packit Bot ea69bd
   determined by the first character in each line:
Packit Bot ea69bd
Packit Bot ea69bd
      '#': Rest of line is a comment, and is ignored.
Packit Bot ea69bd
      '$': Rest of first field is a variable
Packit Bot ea69bd
      '*': Denotes the name of an executable script
Packit Bot ea69bd
Packit Bot ea69bd
      Other than blank lines, the only other declarations are
Packit Bot ea69bd
      reserved variable names, such as LogFile, Archive, etc.
Packit Bot ea69bd
Packit Bot ea69bd
   In general, setting a variable overrides any value previously set.
Packit Bot ea69bd
   However, the following variables are cumulative:
Packit Bot ea69bd
   - In logwatch.conf:  	    LogFile, Service
Packit Bot ea69bd
   - In services/service_name.conf: LogFile
Packit Bot ea69bd
   - In logfiles/service_name.conf: LogFile, Archive
Packit Bot ea69bd
Packit Bot ea69bd
   To remove all previous declarations of that variable, set the
Packit Bot ea69bd
   variable to the empty string.  Duplicate values in the cumulative
Packit Bot ea69bd
   variables are deleted.
Packit Bot ea69bd
Packit Bot ea69bd
   If an executable script is declared in an /etc/logwatch/conf file,
Packit Bot ea69bd
   all of the executable script declarations in the corresponding file
Packit Bot ea69bd
   in /usr/share/logwatch/default.conf or /usr/share/logwatch/dist.conf
Packit Bot ea69bd
   are ignored.
Packit Bot ea69bd
Packit Bot ea69bd
   Because of the way variables and executable scripts are declared,
Packit Bot ea69bd
   the files in /etc/logwatch/conf/ can be created in one of two ways:
Packit Bot ea69bd
Packit Bot ea69bd
   - you can create a file with only the modified variables (and
Packit Bot ea69bd
     new executable script declarations, if needed), as described
Packit Bot ea69bd
     above, or
Packit Bot ea69bd
Packit Bot ea69bd
   - you can copy an entire configuration file from
Packit Bot ea69bd
     /usr/share/logwatch/default.conf to its corresponding location in 
Packit Bot ea69bd
     /etc/logwatch/conf, and then modify those lines that require it.
Packit Bot ea69bd
     Because duplicates are removed from cumulative variables, and
Packit Bot ea69bd
     new executable script groups override the old ones, the output
Packit Bot ea69bd
     should be correct.
Packit Bot ea69bd
Packit Bot ea69bd
2. The /etc/logwatch/conf/override.conf file is then searched.  The first
Packit Bot ea69bd
   field in each line may be one of the following:
Packit Bot ea69bd
Packit Bot ea69bd
      #
Packit Bot ea69bd
           This character indicates that the rest of the line is a
Packit Bot ea69bd
           comment, and is ignored.
Packit Bot ea69bd
Packit Bot ea69bd
      logwatch:
Packit Bot ea69bd
           This string indicates that the rest of the line is a global
Packit Bot ea69bd
           configuration option, and uses the same syntax as the
Packit Bot ea69bd
           /usr/share/logwatch/default.conf/logwatch.conf file.
Packit Bot ea69bd
Packit Bot ea69bd
      services/service_name:
Packit Bot ea69bd
           (Where service_name is the name of a service.)  This string
Packit Bot ea69bd
           indicates that the rest of the line is a configuration
Packit Bot ea69bd
           option for the specified service, and uses the same syntax
Packit Bot ea69bd
           as the /usr/share/logwatch/default.conf/services files.
Packit Bot ea69bd
Packit Bot ea69bd
      logfiles/service_name:
Packit Bot ea69bd
           (Where service_name is the name of a service.)  This string
Packit Bot ea69bd
           indicates that the rest of the line is a configuration
Packit Bot ea69bd
           option for the specified service, and uses the same syntax
Packit Bot ea69bd
           as the /usr/share/logwatch/default.conf/logfiles files.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
   For example, if the file /etc/logwatch/conf/override.conf has the single
Packit Bot ea69bd
   entry:
Packit Bot ea69bd
        logwatch: Detail = High
Packit Bot ea69bd
   then the default detail level for all services will be set to High.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
   And, in file override.conf, the following declaration:
Packit Bot ea69bd
        logfiles/messages: LogFile = syslog
Packit Bot ea69bd
Packit Bot ea69bd
   will analyze the syslog file (in addition to the default messages file)
Packit Bot ea69bd
   for certain services.  But the following two declarations combined:
Packit Bot ea69bd
Packit Bot ea69bd
	logfiles/messages: LogFile = 
Packit Bot ea69bd
	logfiles/messages: LogFile = syslog
Packit Bot ea69bd
Packit Bot ea69bd
   will cause the messages file to be ignored for those same services,
Packit Bot ea69bd
   and only the syslog file will be used.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
5. Customizing the Scripts
Packit Bot ea69bd
==========================
Packit Bot ea69bd
Packit Bot ea69bd
Similarly to the way you can customize the configuration, as
Packit Bot ea69bd
specified in section 4, you can override the default executable
Packit Bot ea69bd
scripts.
Packit Bot ea69bd
Packit Bot ea69bd
This is accomplished by placing an executable file with the same
Packit Bot ea69bd
name and relative path (with respect to /usr/share/logwatch/scripts)
Packit Bot ea69bd
under the /etc/logwatch/scripts directory.  If such a file is
Packit Bot ea69bd
found in the /etc/logwatch/scripts directory, the corresponding
Packit Bot ea69bd
file under /usr/share/logwatch/scripts will be ignored.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
6. Creating New Service Filters
Packit Bot ea69bd
===============================
Packit Bot ea69bd
Packit Bot ea69bd
New services may be created by creating new configuration and
Packit Bot ea69bd
executable files, described above, and placing them in the
Packit Bot ea69bd
/etc/logwatch directory.  This section provides additional
Packit Bot ea69bd
details and examples for creating new service filters, but
Packit Bot ea69bd
it might be easier to base the new files on the existing
Packit Bot ea69bd
configuration and script files under the /usr/share/logwatch
Packit Bot ea69bd
directory.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
A. Logfile Groups
Packit Bot ea69bd
-----------------
Packit Bot ea69bd
Packit Bot ea69bd
There is only one required line in the logfile group config file.  This
Packit Bot ea69bd
command is called 'LogFile'.
Packit Bot ea69bd
Packit Bot ea69bd
# This will be the logfile named 'messages' in the default logfile
Packit Bot ea69bd
# directory (probably /var/log).
Packit Bot ea69bd
LogFile = messages
Packit Bot ea69bd
Packit Bot ea69bd
# You can also give this command with an absolute path, like this:
Packit Bot ea69bd
LogFile = /var/log/messages
Packit Bot ea69bd
Packit Bot ea69bd
You can have as many LogFile entries as you wish.  All the files specified
Packit Bot ea69bd
will be merged into one input stream for any filters that use this logfile
Packit Bot ea69bd
group.  You can also use standard wildcards when you specify the filename.
Packit Bot ea69bd
Packit Bot ea69bd
Another command that is optional is called 'Archive'.  You can specify a
Packit Bot ea69bd
file to also include in the data stream if the '--archives' option is used.
Packit Bot ea69bd
If these files do not exist it is okay.  For example:
Packit Bot ea69bd
Packit Bot ea69bd
# These 2 'Archive' entries will allow users of most Red Hat Linux
Packit Bot ea69bd
# systems to access their archives of the 'messages' logfile:
Packit Bot ea69bd
Archive = messages.?
Packit Bot ea69bd
# If they configure Compression to be on in /etc/logrotate.conf:
Packit Bot ea69bd
Archive = messages.?.gz
Packit Bot ea69bd
# It is best just to include both of these so that the logfile group
Packit Bot ea69bd
# will work for most systems.
Packit Bot ea69bd
Packit Bot ea69bd
Now, the general theory is that the LogFile Group should apply the date
Packit Bot ea69bd
range requested.  If the logfile is in the standard syslog format, you can
Packit Bot ea69bd
use the shared script 'ApplyStdDate' to filter out only the appropriate log
Packit Bot ea69bd
entries.  The way to call shared scripts (located under
Packit Bot ea69bd
/usr/share/logwatch/scripts/shared) is:
Packit Bot ea69bd
Packit Bot ea69bd
*ApplyStdDate = 
Packit Bot ea69bd
Packit Bot ea69bd
Anything following the equal sign will be passed to the program as arguments
Packit Bot ea69bd
(the equal sign can be eliminated if no arguments are needed).  You should
Packit Bot ea69bd
look at the current logfile group config files for examples.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
Finally, if the directory /usr/share/logwatch/scripts/logfiles/<logfile_group_name>/
Packit Bot ea69bd
exists, any scripts in that directory will be executed.  All of these
Packit Bot ea69bd
scripts take the contents of all the specified logfiles in through STDIN and
Packit Bot ea69bd
output the modified logfile trought STDOUT.
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
B. Service Filter Configuration File
Packit Bot ea69bd
------------------------------------
Packit Bot ea69bd
Packit Bot ea69bd
Once you have defined one or more logfile groups (or decided on one or
Packit Bot ea69bd
more existing logfile groups), you need to define your service filter.
Packit Bot ea69bd
Packit Bot ea69bd
This file needs to be in /etc/logwatch/conf/services/ and it needs to be
Packit Bot ea69bd
named service_name.conf, where service_name is the name of the service.
Packit Bot ea69bd
You should probably copy an existing config for another service to create
Packit Bot ea69bd
a new one.  
Packit Bot ea69bd
Packit Bot ea69bd
There is only one required line.  This is the command 'LogFile'.  The
Packit Bot ea69bd
LogFile command allows you to specify one or more *LogFile Groups* (as
Packit Bot ea69bd
described above) that this filter will process.  Remember, any filter can
Packit Bot ea69bd
process any number of LogFile Groups, and any LogFile Group may contain the
Packit Bot ea69bd
data from any number of logfiles (and archives). 
Packit Bot ea69bd
Packit Bot ea69bd
For a service filter that needs messages from /var/log/messages you would
Packit Bot ea69bd
add this line:
Packit Bot ea69bd
Packit Bot ea69bd
LogFile = messages
Packit Bot ea69bd
Packit Bot ea69bd
NOTE:  This is *not* because the name of the logfile is 'messages', but it
Packit Bot ea69bd
is because the name of the LogFile Group that has been defined is
Packit Bot ea69bd
'messages'.
Packit Bot ea69bd
Packit Bot ea69bd
You can have commands in the form of:
Packit Bot ea69bd
Packit Bot ea69bd
*SharedScriptName = Arguments
Packit Bot ea69bd
Packit Bot ea69bd
that will execute a script found in the /usr/share/logwatch/scripts/shared/
Packit Bot ea69bd
directory named 'SharedScriptName' with arguments 'Arguments'.
Packit Bot ea69bd
This filter will modify the input to the service's filter.
Packit Bot ea69bd
Packit Bot ea69bd
You can also have commands in the form:
Packit Bot ea69bd
Packit Bot ea69bd
$EnvironmentVariable = Value
Packit Bot ea69bd
Packit Bot ea69bd
This command will set the 'EnvironmentVariable' environment variable to the
Packit Bot ea69bd
value 'Value'.  This environment variable will be accessable by your filter
Packit Bot ea69bd
program.
Packit Bot ea69bd
Packit Bot ea69bd
You will also usually want to specify a title for your script (new in
Packit Bot ea69bd
Logwatch 4.0).  If specified, then a start and stop delimiter will be added
Packit Bot ea69bd
by Logwatch for your specific service (with your script's output between
Packit Bot ea69bd
those delimiters).  This will *only* happen if you produce output.  If you
Packit Bot ea69bd
produce no output, the headers will not be created.  Here is how you define
Packit Bot ea69bd
your title:
Packit Bot ea69bd
Packit Bot ea69bd
Title = "My Service Title"
Packit Bot ea69bd
Packit Bot ea69bd
Packit Bot ea69bd
C. Service Filter Executable
Packit Bot ea69bd
----------------------------
Packit Bot ea69bd
Packit Bot ea69bd
Once everything above has been done, you are ready to actually write
Packit Bot ea69bd
your filter.  This can be done in any language as all it does is:
Packit Bot ea69bd
1) Read logfile entries from STDIN
Packit Bot ea69bd
2) Access some environment variables
Packit Bot ea69bd
3) Generate a report on STDOUT
Packit Bot ea69bd
Packit Bot ea69bd
Before you try to write a filter, you should create the filter and make its
Packit Bot ea69bd
contents the test script given below.  The filter needs to be located in
Packit Bot ea69bd
/etc/logwatch/scripts/services/ and named service_name (because you named the
Packit Bot ea69bd
config file service_name.conf).
Packit Bot ea69bd
Packit Bot ea69bd
###################### Cut Here #########################
Packit Bot ea69bd
#!/bin/bash
Packit Bot ea69bd
# This is as nice script that will show you the lines you will
Packit Bot ea69bd
# be processing and reporting on.  It will first display the
Packit Bot ea69bd
# standard environment variables and then it takes STDIN and
Packit Bot ea69bd
# dump it right back out to STDOUT.  
Packit Bot ea69bd
Packit Bot ea69bd
# These are the standard environment variables.  You can define
Packit Bot ea69bd
# more in your service config file (see above).
Packit Bot ea69bd
echo "Date Range: $LOGWATCH_DATE_RANGE"
Packit Bot ea69bd
echo "Detail Level: $LOGWATCH_DETAIL_LEVEL"
Packit Bot ea69bd
echo "Temp Dir: $LOGWATCH_TEMP_DIR"
Packit Bot ea69bd
echo "Debug Level: $LOGWATCH_DEBUG"
Packit Bot ea69bd
Packit Bot ea69bd
# Now take STDIN and dump it to STDOUT
Packit Bot ea69bd
cat
Packit Bot ea69bd
###################### Cut Here #########################
Packit Bot ea69bd
Packit Bot ea69bd
If you temporarily replace a script such as 'pam' with the above, you will
Packit Bot ea69bd
notice that much has been cut out of /var/log/messages before it gets to
Packit Bot ea69bd
this filter.  
Packit Bot ea69bd
Packit Bot ea69bd
The value of the environment variable LOGWATCH_DETAIL_LEVEL can be any
Packit Bot ea69bd
integer.  In reality, it is usually 0 (for low), 5 (for medium), and 10
Packit Bot ea69bd
(for high). 
Packit Bot ea69bd
Packit Bot ea69bd
Your script should only produce output as appropriate.  If there are no
Packit Bot ea69bd
relevant log entries, no output should be produced.  Likewise, if you are
Packit Bot ea69bd
reporting two things, such as "Good Logins" and "Bad Logins", you should
Packit Bot ea69bd
only produce even the headers when appropriate.  For example:
Packit Bot ea69bd
Packit Bot ea69bd
Bad Logins:
Packit Bot ea69bd
   amber (2 time(s))
Packit Bot ea69bd
   kirk (3 time(s))
Packit Bot ea69bd
Packit Bot ea69bd
Good Logins:
Packit Bot ea69bd
   amber (5 time(s))
Packit Bot ea69bd
   kirk (10 time(s))
Packit Bot ea69bd
Packit Bot ea69bd
But, if no failed logins occur, you should only output:
Packit Bot ea69bd
Packit Bot ea69bd
Good Logins:
Packit Bot ea69bd
   amber (5 time(s))
Packit Bot ea69bd
   kirk (10 time(s))
Packit Bot ea69bd
Packit Bot ea69bd
Note that there is no "Bad Logins:" header as there were no bad logins.  You
Packit Bot ea69bd
should also use the detail environment variable when deciding what to
Packit Bot ea69bd
output.  Bad logins might always be displayed, but good logins might only be
Packit Bot ea69bd
displayed at higher detail levels.  Here is a guide on how you should
Packit Bot ea69bd
use the detail setting:
Packit Bot ea69bd
Packit Bot ea69bd
0 (Low): Display only errors and security-related issues
Packit Bot ea69bd
5 (Med): Display anything that a typical administator would be interested in
Packit Bot ea69bd
10 (High): Display anything that a paranoid administrator would want to see
Packit Bot ea69bd
Packit Bot ea69bd
In some cases, you can use a security setting higher than 10.  This would be
Packit Bot ea69bd
reserved for information so trivial that it would not even interest the US 
Packit Bot ea69bd
Government.
Packit Bot ea69bd
Packit Bot ea69bd
D. Shared Script Commands
Packit Bot ea69bd
-------------------------
Packit Bot ea69bd
Packit Bot ea69bd
The way to call commands is:
Packit Bot ea69bd
Packit Bot ea69bd
*SharedScriptCommand [= Arguments]
Packit Bot ea69bd
Packit Bot ea69bd
Logwatch will search for the command in /usr/share/logwatch/scripts/shared/ and
Packit Bot ea69bd
/etc/logwatch/scripts/shared/. The command name is case insensitiv and can be
Packit Bot ea69bd
used in logfile and service group configuratin files. Everything after the
Packit Bot ea69bd
equal sign will be passed as arguments to the command.
Packit Bot ea69bd
The following shared scripts are shipped with logwatch (they don't accept any
Packit Bot ea69bd
arguments unless otherwise mentioned):
Packit Bot ea69bd
Packit Bot ea69bd
        - ApplyBindDate
Packit Bot ea69bd
            Filter messages with a time format of '%d-%b-%Y %H:%M:%S'
Packit Bot ea69bd
        - ApplyEuroDate
Packit Bot ea69bd
            Filter messages with a time format of '%Y-%m-%d %H:%M:%S'
Packit Bot ea69bd
        - ApplyHttpDate
Packit Bot ea69bd
            Filter messages with a time format of '%d/%b/%Y:%H:%M:%S'
Packit Bot ea69bd
        - ApplyStdDate
Packit Bot ea69bd
            Without argument filter messages with a time format of
Packit Bot ea69bd
            '%b %e %H:%M:%S' or '%Y-%m-%dT%H:%M:%S\.[0-9]+[+-][0-9]{2}:[0-9]{2}
Packit Bot ea69bd
            which is the ISO8601 logformat
Packit Bot ea69bd
            It accepts one argument which is the filter string, e.g.:
Packit Bot ea69bd
            *applystddate = "%m-%d-%Y %H:%M:%S"
Packit Bot ea69bd
        - ApplyTaiDate
Packit Bot ea69bd
            Filter messages which start with a hex string which represents
Packit Bot ea69bd
            the seconds since 01.01.1970.'
Packit Bot ea69bd
        - ApplyUSDate
Packit Bot ea69bd
            Filter messages with a time format of '%m/%d/%y:%H:%M:%S'
Packit Bot ea69bd
        - ApplyVsftpdDate
Packit Bot ea69bd
            Filter messages with a time format of '... %b %e %H:%M:%S 20%y'
Packit Bot ea69bd
        - EventLogOnlyService
Packit Bot ea69bd
            Filter messages which match: '... .. ..:..:.. .* MSWinEventLog\t\d+\t$ServiceName\t'
Packit Bot ea69bd
            It accepts one argument which is the $ServiceName
Packit Bot ea69bd
        - EventLogRemoveService
Packit Bot ea69bd
            Will remove the unwanted service from a logfile in a WinEventLog
Packit Bot ea69bd
            format. Drops messages which match the pattern in
Packit Bot ea69bd
            EventLogOnlyService. Accepts one argument which is $ServiceName
Packit Bot ea69bd
        - ExpandRepeats
Packit Bot ea69bd
            This used to expand "Last message repeated n Times" messages
Packit Bot ea69bd
            in standard sslog files. But it now ignores these lines, as
Packit Bot ea69bd
            otherwise the temporary logfiles will be too huge.
Packit Bot ea69bd
        - HostHash
Packit Bot ea69bd
            Print all hostnames which occured in a logfile. This matches only
Packit Bot ea69bd
            at default syslog format: '^... .. ..:..:.. ([\w\-\_]+)'
Packit Bot ea69bd
        - HostList
Packit Bot ea69bd
            Write a list of all hostnames which occured in a logfile to
Packit Bot ea69bd
            $LOGWATCH_TEMP_DIR/hostfile. This matches only at default 
Packit Bot ea69bd
            syslog format: '^... .. ..:..:.. (\S*)'
Packit Bot ea69bd
        - MultiService
Packit Bot ea69bd
            This will pick out only the wanted service from a logfile in
Packit Bot ea69bd
            the standard syslog message format. Case insensitive.
Packit Bot ea69bd
            Accepts a comma separated list of service names as argument.
Packit Bot ea69bd
        - OnlyContains
Packit Bot ea69bd
            Just does a case insensitive egrep. Arguments are passed
Packit Bot ea69bd
            directly to egrep.
Packit Bot ea69bd
        - OnlyHost
Packit Bot ea69bd
            This will pick out only lines from $hostname from a logfile in the
Packit Bot ea69bd
            standard syslog format. Case insensitive.
Packit Bot ea69bd
            Set logwatch option LOGWATCH_ONLY_HOSTNAME or pass a comma
Packit Bot ea69bd
            separated list of hostnames as argument to make this work.
Packit Bot ea69bd
        - OnlyService
Packit Bot ea69bd
            This will pick out only the wanted service from a logfile in the
Packit Bot ea69bd
            standard syslog format. Case insensitive. First argument is the
Packit Bot ea69bd
            service name.
Packit Bot ea69bd
        - Remove
Packit Bot ea69bd
            Just a case insensitive, inverse egrep
Packit Bot ea69bd
        - RemoveHeaders
Packit Bot ea69bd
            Remove the beginning of each line of a standard syslog-style,
Packit Bot ea69bd
            Solaris ID tag style or date-prefix-style logfile.
Packit Bot ea69bd
            The pattern to remove is configurable and can be passed
Packit Bot ea69bd
            as the first argument, e.g.:
Packit Bot ea69bd
            * RemoveHeaders = "\d{4}-\d\d-\d\d \d\d:\d\:\d\d "
Packit Bot ea69bd
        - RemoveService
Packit Bot ea69bd
            Remove the unwanted service form a logfile in the standard
Packit Bot ea69bd
            syslog-style message format. Case insensitive.
Packit Bot ea69bd
            It accepts one argument which is a comma separated list of
Packit Bot ea69bd
            service names, e.g.:
Packit Bot ea69bd
            * RemoveService = "myservice,myotherservice"
Packit Bot ea69bd
Packit Bot ea69bd
E. Environment Information
Packit Bot ea69bd
--------------------------
Packit Bot ea69bd
Packit Bot ea69bd
The following Informations can be accessed from environment variables inside
Packit Bot ea69bd
service scripts, e.g.
Packit Bot ea69bd
   print "service logfile list: $ENV{'LOGWATCH_LOGFILE_LIST'}"
Packit Bot ea69bd
Packit Bot ea69bd
         - LOGWATCH_LOGFILE_LIST
Packit Bot ea69bd
             space separated list of logfiles which are configured for that
Packit Bot ea69bd
             service.
Packit Bot ea69bd
Packit Bot ea69bd
         - LOGWATCH_ARCHIVE_LIST
Packit Bot ea69bd
             space separated list of archive files which are configured for
Packit Bot ea69bd
             that service.
Packit Bot ea69bd
Packit Bot ea69bd
         - TODO list other env variables.
Packit Bot ea69bd
Packit Bot ea69bd
7. For More Information
Packit Bot ea69bd
=======================
Packit Bot ea69bd
Packit Bot ea69bd
The introduction of this document listed additional sources of information.
Packit Bot ea69bd
In addition, the website http://www.logwatch.org contains:
Packit Bot ea69bd
	- the current (and some archived) distributions of Logwatch
Packit Bot ea69bd
	- access to mailing lists where comments, suggestions, bug reports,
Packit Bot ea69bd
	  etc., are welcome.
Packit Bot ea69bd
	- access to the svn repository, for the very latest code.
Packit Bot ea69bd
Packit Bot ea69bd
If you do create new services or enhancements that you feel would be useful
Packit Bot ea69bd
to other people, please send them to the mailing list 'logwatch-devel at
Packit Bot ea69bd
lists.sourceforge.net'.
Packit Bot ea69bd
Packit Bot ea69bd
If you send patches, please make sure that you have the latest version
Packit Bot ea69bd
of the file from svn, and send the patch file in unified format
Packit Bot ea69bd
(using 'svn diff' or 'diff -u') as an attachment.
Packit Bot ea69bd
Packit Bot ea69bd
Enhancement suggestions are more likely to be implemented if patch files
Packit Bot ea69bd
implementing the change are sent.