centos6.5安装logwatch监控日志
Logwatch是使用 Perl 开发的一个日志分析工具
Logwatch能够对Linux 的日志文件进行分析,并自动发送mail给相关处理人员,可定制需求
Logwatch的mail功能是借助宿主系统自带的mail server 发邮件的,所以系统需安装mail server , 如sendmail,postfix,Qmail等
本文yum安装配置
yum install -y logwatch
【 配置 】
a. 配置文件在 /etc/logwatch , 相关配置模板在 /usr/share/logwatch
cp /usr/share/logwatch/default.conf/logwatch.conf /etc/logwatch/conf/logwatch.conf
如果不做这一步 , /etc/logwatch/conf/logwatch.conf 是一个空文件
默认配置会使用 /usr/share/logwatch/default.conf/logwatch.conf
b. vim /etc/logwatch/conf/logwatch.conf
LogDir = /var/log logwatch 会去 /var/log 找你定义的 log 文件
TmpDir = /var/cache/logwatch
# Save = /tmp/logwatch 开启此项, 处理结果将保存在/tmp/logwatch, 不邮寄或显示
MailTo = your@mail.com 多个邮箱逗号隔开
MailFrom = Logwatch 当你收到邮件时, 显示是谁发给你的
Range = All 处理什么时候的日志 , 可选项 All , Yesterday , Today , 即所有, 昨天的 , 今天的
Detail = High 日志详细度, 可选项 Low , Med , High , 或是 0-10数字
Print = No 可选项, Yes 会被打印到系统标准输出, 并且不会以邮件的形式发送到 MailTo 设定的邮箱里 , No 选项则会发到邮箱中
Server = All 监控所有服务 all
Service = “-httpd” 不监控的服务前面加 “-” , 如 -httpd , 即不监控 httpd 服务 , 可以写多条
Service = “-sshd”
【 Logwatch 使用 】
a. 配置好以后 , 使用如下命令测试
/usr/bin/perl /usr/share/logwatch/scripts/logwatch.pl
你会发现没有 httpd , sshd 服务的日志报告 ,
去掉 Service = “-sshd” 配置 , 再执行上面命令 , 就可以看到 sshd 服务的 report 了
b. Logwatch 并不是以系统服务形式来跑的 , 而是靠在命令行上敲的 , 所以可以使用 crontab 来定时执行
在配置好 Logwatch 后 , 会生成一个软链 /etc/cron.daily/0logwatch , 对应文件为 /usr/share/logwatch/scripts/logwatch.pl
你可以删除这个软链 , 并重写 crontab :
* 00 * * * /usr/bin/perl /usr/share/logwatch/scripts/logwatch.pl >/dev/null 2>&1
【 Logwatch 命令行使用 】
Logwatch 也可以在命令行上使用, 如下例子:
logwatch –detail High –Service All –range All –print # 显示所有日志, –detail , –Service, –range 开关可以在 logwatch.conf 中 找到
logwatch –service cron –detail High # 查看 sshd 日志
以下是 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日志报告邮件 , 请检察本地 sendmail 服务是否正常
直接指定邮件发送
#logwatch --range today --print --mailto sina@sina.com 当天
/usr/share/logwatch/scripts/logwatch.pl --mailto sina@sina.com
centos6.5安装logwatch监控日志的更多相关文章
- CentOS6.9安装Filebeat监控Nginx的访问日志发送到Kafka
一.下载地址: 官方:https://www.elastic.co/cn/downloads/beats/filebeat 百度云盘:https://pan.baidu.com/s/1dvhqb0 二 ...
- centos6 x86 安装 oracle 11g2r 日志
一.安装centos 6.5 二.安装ora所需的库 三.修改centos内核 四.建用户组和目录结构等 五.安装ora11g2r 六.安装sqlplus的翻页程序和help补丁 七.自启动脚本 八. ...
- CentOS6.4 安装LVS-RRD监控LVS
1.安装依赖包 yum install -y php httpd bc rrdtool 启动apache (我看网上的一些文档说不能用80端口,但我用80端口试了一下也好使,如果出现不好使的情况就改一 ...
- centos7安装Logwatch配合msmtp邮件客户端发送服务器监控分析日志
########################### #DATE 2016-07-29 # #Authur by Denilas Yeung ...
- 如何在 Ubuntu 15.04 系统中安装 Logwatch
大家好,今天我们会讲述在 Ubuntu 15.04 操作系统上如何安装 Logwatch 软件,它也可以在各种 Linux 系统和类 Unix 系统上安装.Logwatch 是一款可定制的日志分析和日 ...
- Centos6 yum安装openldap+phpldapadmin+TLS+双主配置
原文地址:http://54im.com/openldap/centos-6-yum-install-openldap-phpldapadmin-tls-%E5%8F%8C%E4%B8%BB%E9%8 ...
- centos6.4安装配置vpn服务器步骤详解
centos6.4安装配置vpn服务器步骤详解,从安装VPN到配置VPN服务器.配置VPN服务器的路由转发功能,每一步都很详细 一.VPN服务器环境说明 操作系统:CentOS release ...
- 阿里云CentOS6.3 安装MongoDB教程
安装说明 系统环境:Centos-6.3安装软件:mongodb-linux-x86_64-2.2.2.tgz下载地址:http://www.mongodb.org/downloads安装机器:192 ...
- Centos6.9安装vsftpd并配置多用户的方法
本文介绍了Centos6.9安装vsftpd并配置多用户的方法,分享给大家,具体如下: 一.安装vsftpd ? 1 2 3 4 5 6 7 8 #安装vsftpd yum -y install vs ...
随机推荐
- 禁止requests请求https的提示InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more
提示这个 InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from ...
- MTK 永不熄屏
步骤一: 源码/frameworks/base/packages/SettingsProvider/res/values/defaults.xml 修改<integername=</int ...
- winform命名规范
我们知道Button 常常简称为btn,那么Winform中的其它控件呢,这篇文章在C#的winform控件命名规范 的基础上对一些控件的名称的简称进行了整理. 1. 标准控件 NO. 控件类型简写 ...
- 8 -- 深入使用Spring -- 1...4 重写占位符配置器
8.1.5 重写占位符配置器 (PropertyOverrideConfigurer) PropertyOverrideConfigurer是Spring提供的另一个容器后处理器.PropertyOv ...
- form enctype:"multipart/form-data",method:"post" 提交表单,后台获取不到数据
在解决博问node.js接受参数的时候,发现当form中添加enctype:"multipart/form-data",后台确实获取不到数据,于是跑到百度上查了一下,终于明白为什么 ...
- 解决ora-01034和ora-27101错误
使用plsql登录oracle数据库,提示如下错误: 定位原因:tnsnames.ora文件中数据库的配置参数有误所致 解决办法:将SERVICE_NAME修改为SID即可
- CopyTransform
// TransformCopier.cs v 1.1 // homepage: http://wiki.unity3d.com/index.php/CopyTransform using Unity ...
- html主要笔记
1.用title属性作为工具提示 2.链接到锚点 <a href="http://wickedlysmart.com/buzz#Coffee"> 3.<em> ...
- linux系统抓包命令
IP地址抓包:tcpdump -i any host 1.1.1.2 -n 端口抓包: tcpdump -i any port 6789 -n wireshak工具抓包:tcp.port == 678 ...
- 《C++标准程序库》笔记之四
本篇博客笔记顺序大体按照<C++标准程序库(第1版)>各章节顺序编排. ---------------------------------------------------------- ...