zoukankan      html  css  js  c++  java
  • [Linux]配置Logwatch使用第三方smtp发送电子邮件

    一、Logwatch介绍

    Logwatch是一款专门监测Linux日志的软件。它可以将日志统计分析并通过邮件发送给指定收件人[1][2]。

    二、背景

    一个基于CentOS6.1的实验用Linux集群。由于其架设在内网,没有公网IPv4地址。而所采用的DNS服务商又不支持AAAA记录。因此打算使用其他SMTP将日志发送到我的邮箱。

    三、过程

    1.首先配置mailx所使用的SMTP。修改/etc/mail.rc并添加smtp身份认证信息[3]。例如

    set from=monitor@yourdomain.com
    set smtp=smtp.yourdomain.com
    set smtp-auth=login
    set smtp-auth-user=monitor
    set smtp-auth-password=PassWord

    2.我发现/etc/cron.daily/0logwatch中,任务使用了默认配置文件/usr/share/logwatch/default.conf/logwatch.conf ,因此修改该配置文件

    第35行 MailTo = 接收日志用的邮箱,多个邮箱用英文逗号分隔

    第44行 MailFrom = monitor@yourdomain.com #由于部分SMTP不允许邮件别名,建议此地址与mailx配置的发件人相同。

    第109行 mailer = "mailx -t" #将邮件客户端更换为mailx。其中-t参数表示从内容中直接读取邮件头。参考 man mailx

    3.手动执行logwatch。等待一会儿,就会收到邮件。如果失败,可以查看系统日志或者在系统中执行mail,查看用户的本地邮件。

    OT. 在配置Rocks Cluster时若需要让全部节点将日志都使用外部smtp发送邮件,需要手动修改所有节点的上述文件。

    [1] http://sourceforge.net/projects/logwatch/

    [2] http://dbanotes.net/opensource/logwatch_linux_log.html

    [3] http://lwg2001s.iteye.com/blog/1826020

  • 相关阅读:
    前端之HTML
    面向对象编程思想
    【统计】Causal Inference
    Python 最常见的 170 道面试题全解析:2019 版
    面试mysql表设计要注意啥
    数据分析资料汇总
    【crunch bang】论坛tint2配置讨论贴
    【crunch bang】增加壁纸图片文件
    【linux】xx is not in the sudoers file 解决办法
    【crunch bang】安装firefox,删除iceweasel
  • 原文地址:https://www.cnblogs.com/sztsian/p/3451729.html
Copyright © 2011-2022 走看看