Logwatch Weekly

I like Logwatch, but I don't like how it defaults to daily notifications, and it places the disk information at the very bottom (when this is the "at a glance" information I mostly care about).

This guide assumes you already have mail working (along with /etc/aliases configured).


Install Logwatch:

pkg install logwatch

Install Perl's date manipulation routines:

pkg install p5-Date-Manip

Create (or edit) /usr/local/etc/logwatch/logwatch.conf with the following:

#
# Linux:
# /etc/logwatch/conf/logwatch.conf
#
# FreeBSD:
# /usr/local/etc/logwatch/logwatch.conf
#

# switch from daily to weekly
Range = between -7 days and -1 days

# make sure we output to mail
Output = mail

# increase detail level above 0 / low
Detail = 4

# exclude the "bottom" df script since we have a "top" script
Service = "-zz-disk_space" 

# EoF

Create (or edit) /usr/local/etc/logwatch/services/00-disk.conf with the following:

#
# Linux:
# /etc/logwatch/conf/services/00-disk.conf
#
# FreeBSD:
# /usr/local/etc/logwatch/services/00-disk.conf
#

# report title
Title = "Disk Space"

# which logfiles
LogFile = NONE

# Uncomment this to show the system directory sizes /opt /usr/ /var/log
# $show_disk_usage = 1

# The variables df_options and disk_cmd are used to customize the
# reporting of filesystem disk usage.
$disk_cmd = "df $df_options"

# FreeBSD
$df_options = "-h -t nodevfs,linprocfs,linsysfs,tmpfs"

# For Linux
# $df_options = "-h -l -x tmpfs -x devtmpfs"

# print a warning if the disk utilization exceeds this number.
# the default is 90. set to 0 if no warning desired.
# $diskfull_threshold = 0

# exclude directories from disk full warnings
# $diskfull_exclude_dirs = /run/media

# EoF

Copy the original disk service to our new name:

mkdir -p /usr/local/libexec/logwatch/services
cp -a /usr/local/libexec/logwatch/defaults/services/zz-disk_space /usr/local/libexec/logwatch/services/00-disk

Add a crontab entry to run Logwatch weekly:

# 5am, sunday, run logwatch
0 5 * * 0 /usr/local/sbin/logwatch.pl 

You can test the new format:

/usr/local/sbin/logwatch.pl