首页 » 操作系统 » Linux » 正文

Logwatch 自定义邮件中的 httpd 记录格式

发布者:站点默认
2012/07/12 浏览数(1,804) 分类:Linux, 未分类 Logwatch 自定义邮件中的 httpd 记录格式已关闭评论

说明:

logwatch 邮件中 httpd 部分的显示通常会是下边的样子,但是服务器上有N多个网站、网站的目录名称相同的也很多,将其对应到相应的网站上将会耗费大量时间。

Requests with error response codes
    400 Bad Request
       /: 5 Time(s)
       /100117/small/2012051116812204yGwm.jpg: 1 Time(s)
       /customer/uploadfile/1324/1324_201203251308211pYHL.JPG: 1 Time(s)
       /customer/uploadfile/1324/1324_20120325130927ct0zU.JPG: 1 Time(s)
       /customer/uploadfile/1324/1324_20120419195517AtZXx.JPG: 1 Time(s)
       /customer/uploadfile/1324/1324_20120427191205C3uxx.JPG: 1 Time(s)
       /customer/uploadfile/1324/1324_20120427191205WfeRy.JPG: 1 Time(s)

我需要的邮件内容格式(往下看会有实现方法):

Requests with error response codes
    400 Bad Request
       test.upall.cn/: 5 Time(s)
       test.upall.cn/100117/small/2012051116812204yGwm.jpg: 1 Time(s)
       bbs.upall.cn/customer/uploadfile/1324/1324_201203251308211pYHL.JPG: 1 Time(s)
       www.upall.cn/customer/uploadfile/1324/1324_20120325130927ct0zU.JPG: 1 Time(s)
       home.upall.cn/customer/uploadfile/1324/1324_20120419195517AtZXx.JPG: 1 Time(s)
       bbs.upall.cn/customer/uploadfile/1324/1324_20120427191205C3uxx.JPG: 1 Time(s)
       blog.upall.cn/customer/uploadfile/1324/1324_20120427191205WfeRy.JPG: 1 Time(s)

具体操作步骤如下:

1、编辑“/etc/httpd/conf/httpd.conf”,添加一个LogFormat:

LogFormat "%h %V %l %u %t \"%m %{Host}i%U%q %H\" %>s %b" logwatch

2、将“CustomLog”使用的“LogFormat”换为“logwatch”,类似:

#CustomLog logs/access_log combined
#CustomLog "|/usr/sbin/cronolog /etc/httpd/logs/access_log.%Y%m%d" combined
CustomLog "|/usr/sbin/cronolog /etc/httpd/logs/access_log.%Y%m%d" logwatch

3、重启 httpd:

service httpd graceful

<完。方法来自:http://blog.jachim.be/2009/11/hostnames-in-logwatch-reports/

点击返回顶部
  1. 留言
  2. 联系方式