Linux工具系列——logWatch
2017-03-03 本文已影响0人
田七西西
工欲善其事必先利其器!当我们花时间把很厉害的工具用到Linux里后,所有的投入都会带来可观的回报。
工具
logWatch
功能
日志分析,自动发送mail,需求定制
原理
借助系统自带的mail server 发邮件的,所以系统需安装mail server , 如sendmail,postfix,Qmail等
安装
Redhat、Centos : yum install logwatch
Debian、Ubuntu : apt-get install logwatch
配置
配置文件在 /etc/logwatch , 相关配置模板在 /usr/share/logwatch
cp /usr/share/logwatch/default.conf/logwatch.conf /etc/logwatch/conf/logwatch.conf
以下是 logwatch 的参数解释:
–detail < level>: 报告的详细度,可选项: High, Med, Low , 数字 0-10
–logfile < name>: 指日志文件名
–service < name>: 服务名,有对应的解析脚本,可以在 /usr/share/logwatch/scripts/services 中找到
–print: 打印打标准输出
–mailto < addr>: 收件人地址
–archives: 使用压缩的文件, 轮转的文件, 例如 messages.1、messages.1.gz
–save < filename>: 保存到文件
–range < range>: 日期范围, Yesterday, Today, All
–debug < level>: 调试级别: High, Med, Low
–splithosts: 为每个主机创建一份报告
–multiemail: 将报告发送给多个邮件地址
测试
logwatch --range today --print --mailto yourmail@xx.com