Banana Pi 測試 – 使用 logwatch 寄送 Log 檔

在使用 CentOS Linux 時都會使用 logwatch,每天固定寄送系統 Log 給系統管理者,藉此了解目前系統使用的狀況。
在 Banana Pi 因為是拿來當做 Server 使用,所以也另外安裝了 logwatch
# apt-get install logwatch

設定寄給 root 的信件轉寄給會常收信的使用者
# echo “root: test@gmail.com” >> /etc/aliases

讓設定生效
# /usr/bin/newaliases[@more@]但設定完成之後,卻一直收不到相關的信件

查看一下系統 mail 的狀態
# /usr/bin/mailq
27h  4.3K 1XWuzr-0002FO-47 <> *** frozen ***
          root@bananapi
3h  6.5K 1XXHTP-0002×8-Q2 <> *** frozen ***
          root@bananapi
14m  6.6K 1XXKHz-0003cA-4m <> *** frozen ***
          root@bananapi
13m  1.2K 1XXKJ2-0003ca-Oa <> *** frozen ***
          root@bananapi

因為 Debian 的 mail server 是使用 exim4,所以查看一下 mail server 的相關記錄
# head -5 /var/log/exim4/mainlog
2014-09-26 06:32:22 Start queue run: pid=11655
2014-09-26 06:32:22 1XWuzr-0002FO-47 Message is frozen
2014-09-26 06:32:22 1XWYWS-0001UY-F3 Unfrozen by errmsg timer
2014-09-26 06:32:22 1XWYWS-0001UY-F3 ** test@gmail.com <root@bananapi> R=nonlocal: Mailing to remote domains not supported
2014-09-26 06:32:22 1XWYWS-0001UY-F3 test@gmail.com <root@bananapi>: error ignored

發現有 Mailing to remote domains not supported 的訊息,主要是 exim4 在沒有特別設定時,是只能在 local 端運作,無法遠端寄信

設定 exim4
#
# sed -i ‘/configtype/s/local/internet/’ /etc/exim4/update-exim4.conf.conf

# /usr/sbin/exim4 -bV
Exim version 4.80 #3 built 02-Jan-2013 19:15:12
Copyright (c) University of Cambridge, 1995 – 2012
(c) The Exim Maintainers and contributors in ACKNOWLEDGMENTS file, 2007 – 2012
Berkeley DB: Berkeley DB 5.1.29: (October 25, 2011)
Support for: crypteq iconv() IPv6 GnuTLS move_frozen_messages DKIM
Lookups (built-in): lsearch wildlsearch nwildlsearch iplsearch cdb dbm dbmjz dbmnz dnsdb dsearch nis nis0

passwd
Authenticators: cram_md5 plaintext
Routers: accept dnslookup ipliteral manualroute queryprogram redirect
Transports: appendfile/maildir/mailstore autoreply lmtp pipe smtp
Fixed never_users: 0
Size of off_t: 8
Configuration file is /var/lib/exim4/config.autogenerated

# /etc/init.d/exim4 restart
[ ok ] Stopping MTA for restart: exim4_listener.
[ ok ] Restarting MTA: exim4

echo “Hello ! ” | mail -s “My Testing Mail”