Logwatch is a great utility for scanning your Linux system's log files and sending you a daily report. Installing Logwatch on most Linux distributions is as simple as using your package manager. In my case on Ubuntu (8.04LTS) I simply type ' $ sudo apt-get install logwatch' but making it work is not always as simple.
Logwatch requires the system to have an MTA (Message Transfer Agent) such as 'sendmail' or 'postfix' to do its mail delivery work as do most well behaved mail utility programs. The idea is that the system should look after delivery of mail, retries on unreachable servers and so on, not the utility, ie 'logwatch'.
On Ubuntu when you install Logwatch, the installer checks to see if an MTA is present on the system and if so is happy. If no MTA is present, the MTA 'postfix' is automatically installed. There is plenty of information out there on configuration of either 'postfix' or 'sendmail'. My problem however is that my 'Domino Server' does not fulfil the role of a valid system MTA and the installation of 'postfix' or 'sendmail' will clobber operation of Domino Server for mail operations. This is a problem not just for systems running a Domino Server but for any system running an SMTP/SMPTS mail server with no system MTA capability.
There are at least two immediate solutions to this problem.
a) Configure either 'postfix' or 'sendmail' for non standard ports and use it to relay all system mail message to the non MTA mail server, or
b) Modify the implementation of 'logwatch' to deliver messages directly to the non MTA mail server using a simple SMTP utility program such as 'nbsmtp'
I choose option b) as being the simplest and here is my solution.
1. Install 'logwatch' ( $ sudo apt-get install logwatch) and simply accept that 'postfix' will also be installed.
2. Install 'nbsmtp' ( $ sudo apt-get install nbsmtp) which complains about uninstalling 'postfix' due to the 'logwatch' dependency.
3. Properly disable 'postfix' by editing '/etc/init.d/postfix' and inserting the line 'exit 0' at the start of the script.
4. Modify '/etc/cron.daily/00logwatch' to use 'nbsmtp' instead of the system MTA.
Here is an example of my new '/etc/cron.daily/00logwatch' file.
================================================
# !/bin/bash
MAILSERVER = mail.somedomain.com
SENDFROM = root@localdomain.com
SENDTO = admin@somedomain.com
#Check if removed-but-not-purged
test -x /usr/share/logwatch/scripts/logwatch.pl || exit 0
#execute
echo "From: $SENDFROM" > /tmp/mymailinput
echo "To: $SENDTO" >> /tmp/mymailinput
echo "Subject: Logwatch for $HOSTNAME (Linux)" >> /tmp/mymailinput
echo "" >> /tmp/mymailinput
/usr/sbin/logwatch >> /tmp/mymailinput
/usr/bin/nbsmtp -d $FROMDOMAIN -f $SENDFROM -h $MAILSERVER -V -M p < /tmp/mymailinput
================================================
If you also need authenticated login to your destination mail server then you can add the necessary parameters to the last line. It might end up looking something like this (not tested)
/usr/bin/nbsmtp -d $FROMDOMAIN -f $SENDFROM -h $MAILSERVER -V -U $USERNAME - P $PASSWORD < /tmp/mymailinput
If you you decide you really do need an MTA as well then please let me know how you go.
...Robert