浏览代码

Set log watch to weekly per http://primozverdnik.com/2011/05/logwatch-once-a-week-is-enough/

Also mailing to root (which gets forwarded to admin_email) for easier automated sorting
Luke Cyca 11 年前
父节点
当前提交
d71bf5632d
共有 2 个文件被更改,包括 15 次插入3 次删除
  1. 12
    3
      roles/monitoring/tasks/logwatch.yml
  2. 3
    0
      roles/monitoring/templates/etc_logwatch_conf_logwatch.conf.j2

+ 12
- 3
roles/monitoring/tasks/logwatch.yml 查看文件

@@ -1,5 +1,14 @@
1 1
 - name: Install logwatch
2
-  apt: pkg=logwatch state=installed
2
+  apt: pkg={{ item }} state=installed
3
+  with_items:
4
+    - logwatch
5
+    - libdate-manip-perl
3 6
 
4
-- name: Configure logwatch to email {{ admin_email }} daily
5
-  action: lineinfile dest=/etc/cron.daily/00logwatch regexp="^/usr/sbin/logwatch" line="/usr/sbin/logwatch --output mail --mailto {{ admin_email }} --detail high" state=present create=yes
7
+- name: Configure logwatch
8
+  template: src=etc_logwatch_conf_logwatch.conf.j2 dest=/etc/logwatch/conf/logwatch.conf
9
+
10
+- name: Remove logwatch's dist cronjob
11
+  file: state=absent path=/etc/cron.daily/00logwatch
12
+
13
+- name: Configure weekly logwatch cronjob
14
+  cron: special_time=weekly job=/usr/sbin/logwatch name=logwatch

+ 3
- 0
roles/monitoring/templates/etc_logwatch_conf_logwatch.conf.j2 查看文件

@@ -0,0 +1,3 @@
1
+Detail = High
2
+Output = mail
3
+Range = between -7 days and -1 days

正在加载...
取消
保存