Install Logwatch on Centos7 and use the msmtp mail client to send server monitoring and analysis logs
###########################
# DATE 2016-07-29 #
# Authur by Denilas Yeung #
###########################
1. Install msmtp
Download msmtp: http://jaist.dl.sourceforge.net/project/msmtp/msmtp/1.6.5/msmtp-1.6.5.tar.xz
Because the file format is xz, the decompression method is:
# Xz-d msmtp-1.6.5.tar.xz
# Tar xvf msmtp-1.6.5.tar
# Cd msmtp-1.6.5
#./Configure -- prefix =/user/local/msmtp
# Make
# Make install
#/Usr/local/msmtp/bin/msmtp-P # Check the path of the configuration file. The configuration file for Centos7 is created under/usr/local/etc, centos6.x create an msmtprc file under/usr/local/msmtp/etc/
# Vi/usr/local/etc/msmtprc
Account accountname
Logfile/usr/local/msmtp. log
Host smtp.xxx.com
Port 25
From xxx@xxx.com
Auth login
Tls off
User xxx@xxx.com
Password
Account default: accountname
# Save and exit
#/Usr/local/msmtp/bin/msmtp xxx@xxx.com # test whether mail can be sent
Now, msmtp configuration is complete.
######################################## ######################################## #########
Ii. install and configure logwatch
# Yum-y install logwatch
# Whereis logwatch # view the default configuration file/usr/share/logwatch/default. conf in the system folders after logwatch is installed.
# Vi/usr/share/logwatch/default. conf/logwatch. conf # modify the following parameters:
MailTo = Email address of the recipient
MailFrom = who sent
Detail = Low ro Med or High # details of the System Log Analysis Report: simple, moderate, and detailed
Mailer = "/usr/local/msmtp/bin/msmtp-t" # The default value is sendmail, Which is changed to the msmtp path.
# Save and exit
#/Usr/share/logwatch/scripts/logwatch. pl -- mailto xxx@xxx.com # test whether the current system log analysis report is sent to a xxx@xxx.com email and check whether it is received. By default, the system sends the report of the previous day, which can be modified in the configuration file.