Think before you speak, read before you think.

linux工具之logwatch

by

in

logwatch的下载地址:

http://sourceforge.net/projects/logwatch

Logwatch是一个可定制的日志分析系统。使用Perl语言编写。

Logwatch通过系统的日志分析,并创建一个报告,分析您所指定的区域。 Logwatch易于管理,在大多数系统上都可以使用。

ubuntu安装:

sudo apt-get install logwatch

用法:

Usage: /usr/sbin/logwatch [–detail <level>] [–logfile <name>] [–output <output_type>]
[–format <format_type>] [–encode <enconding>] [–numeric]
[–mailto <addr>] [–archives] [–range <range>] [–debug <level>]
[–filename <filename>] [–help|–usage] [–version] [–service <name>]
[–hostformat <host_format type>] [–hostlimit <host1,host2>] [–html_wrap <num_characters>]

用法举例:

如不加–range,则默认是昨天到今天的区间

0.查看帮助信息/查看时间区间的用法

# logwatch --help
# logwatch --range Help

1.查看日志,显示比较全的信息

# logwatch

2.查看某服务sshd日志

# logwatch --service sshd

3.查看近三天的cron日志

logwatch --service cron --range '-3 days'

4.查看sshd的日志,并发送邮件(需配置好邮件服务器,可以对外发邮件)

# logwatch --service sshd --mailto [email protected]

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *