This guide shows you how to analyze system logs with logcheck.
Getting Started With logcheck
logcheck is an updated version of
logsentry (from the
sentrytools package), which is a tool to analyze the system logs. Additionally,
logcheck comes with a built-in database of common, not-interesting log messages to filter out the noise. The general idea of the tool is that all messages are interesting, except the ones explicitly marked as noise.
logcheck periodically sends you an e-mail with a summary of interesting messages.
It is strongly recommended to remove logsentry if you have it installed on your system. Additionally, you should remove /etc/logcheck to avoid permission and file collision problem.
Now you can proceed with the installation of logcheck.
logcheck creates a separate user "logcheck" to avoid running as root. Actually, it will refuse to run as root. To allow it to analyze the logs, you need to make sure they are readable by logcheck. Here is an example for
## (Make log files group-readable by logcheck)
Now reload the configuration and make sure the changes work as expected.
You should now adjust some basic
logcheck settings in /etc/logcheck/logcheck.conf .
CodeBasic /etc/logcheck/logcheck.conf setup
# Controls the level of filtering:
# Can be Set to "workstation", "server" or "paranoid" for different
# levels of filtering. Defaults to server if not set.
## (The workstation level includes server, and server includes paranoid.
The paranoid level filters almost no messages)
# Controls the address mail goes to:
# *NOTE* the script does not set a default value for this variable!
# Should be set to an offsite "firstname.lastname@example.org"
## (Make sure you can receive the logcheck e-mails. Testing is strongly
# Controls if syslog-summary is run over each section.
# Alternatively, set to "1" to enable extra summary.
# HINT: syslog-summary needs to be installed.
## (If you get a lot of similar messages in the logs, you
may want to install app-admin/syslog-summary and enable
You also have to tell
logcheck which log files to scan ( /etc/logcheck/logcheck.logfiles ).
CodeBasic /etc/logcheck/logcheck.logfiles setup
## (This is an example for syslog-ng)
Finally, enable the logcheck cron job.
For more information about cron read the Cron Guide
Congratulations! Now you will be regularly getting important log messages by email. An example message looks like this:
CodeExample logcheck message
Feb 10 17:13:53 localhost kernel: [30233.238342] conftest: segfault at 40 ip 40061403 sp bfc443c4 error 4
Feb 11 12:31:21 localhost postfix/pickup: fatal: could not find any active network interfaces
Feb 11 12:31:22 localhost postfix/master: warning: process //usr/lib/postfix/pickup pid 18704 exit status 1
Feb 11 12:31:22 localhost postfix/master: warning: //usr/lib/postfix/pickup: bad command startup -- throttling
You can use the logcheck's
-d switch to display more debugging information. Example:
We would like to thank the following authors and editors for their contributions to this guide: