Blank lines and leading spaces and tabs are ignored. Lines whose first character is a pound/hash sign (#) are considered comments unless the first two characters of the line are #: in which case it is a configuration line with a defined syntax. Tokens are embedded in comment lines and begin with `:' so a configuration line will look like "#:TOKEN ".
As of Chklogs version 2.0 an alternative notation can be used, so that configuration lines can begin with a dash (-) rather than the two-character sequence, thus #:TOKEN value is equivalent to -TOKEN value , all tokens are case insensitive.
The configuration file has two blocks: Settings and Instructions exactly in that order.
# Chklogs v1.9 Configuration (Enhanced syntax since v1.8) #:Options global #:Global /var/log/chklogs
The first line is just a comment and can be anywhere within the file. The second line tells chklogs that we are about to set options. The options after the token is a whitespace separated list of options. Currently the following options are supported:
The global and local options are mutually exclusive, but if you neglect these instructions and indicate both global and local options the program will work in global mode.
The third line contains the global token (not to be confused with option!) with a parameter/value that represents a directory name. This directory is the root of the Global Repository and is used if the global option is specified, otherwise it is ignored.
This section is the same you know from older (pre v1.8) versions of chklogs with a few enhancements. Older versions of chklogs will still work properly. In this block you can place three types of lines: comments, group definitions and specification lines.
An instruction line is of the form:
Fully-Qualified-Log-Name Threshold Action [Parameters]
The first field is the fully qualified filename of the log, therefore an absolute path. As of version 1.8 this can also be simply a directory name in which case ChkLogs will check all the regular files (non-archives, non-directories) in the directory thus saving you from manually entering all the names in the configuration file.
The second field is the threshold at which chklogs should perform the specified action. As of v1.8 you can have not only size-based but also time-based thresholds. If the threshold contains only digits then this is assumed to be a maximum size in bytes.
If on the other hand the threshold is a sequence of digits followed (without spaces in between!) by either `D' or `M' then it is assumed to be the maximum allowed age of the log in Days or Months respectively. For example:
The `d' and `m' qualifiers are case insensitive.
The Action field can be either archive or truncate or execute. Archive takes a compulsory parameter indicating what is the maximum number of archives you want to keep, when the maximum is reached ChkLogs performs Log Shuffling so that your disk space isn't wasted with archives.
The Truncate action takes no parameter and indicates that if the threshold condition is met ChkLogs is to truncate the file to zero size (you have been warned!).
Finally the Execute action takes one or more parameters. The first being the name of the program or script that you want to be executed when the threshold is reached. This program will always get the fully qualified log name as the first parameter!. If you specify other parameters after the program name then these will also be passed after the fully qualified logname, therefore as parameters 2..n.
Here are some examples of the three cases:
/var/log/sendmail.st 1m execute cdk_mailstats /var/log/sendmail.st 1m archive 3 /var/log/messages 15000 truncate /var/log/cron 20d truncate
In addition to specification lines you can create groups of logs. For each group of logs you can specify what program to execute before the first log is checked and which program to execute (not necessarily the same) after the last log of the group is checked. These pre and post executions are done regardless of whether any of the grouped logs reached a threshold. An trivial example would be:
#:group innd #:Pre /usr/sbin/ctlinnd pause #:Post /usr/sbin/ctlinnd go /var/log/news/ 10d archive 5 # A comment line is compulsory here
The group name is a unique identifier that is used as a directory name where the logs are archived (under the Global Repository) if the global option is used, otherwise it is just a reference. The 'common' group name is reserved.
The next two token lines (Pre/Post) specify which program (plus parameters) are to be executed before and after the group is checked. The end of a log group is delimited by a comment or empty line (be warned! this is a common configuration error!). Do note that even if you do not want or need Pre or Post commands you still must specify the Pre and Post entries, but leave them empty!. Example:
# A Group Definition Without Pre/Post-processing #:group samba #:Pre #:Post /var/log/samba.nmb 10d archive 5 /var/log/samba.smb 10d archive 5 # A comment line is compulsory here
/etc/chklogs.conf
Didimo Emilio Grimaldo Tunon <grimaldo@panama.IAEhv.nl>