瀏覽代碼

Enable E-Mail notifications from Monit

Thomas Buck 5 年之前
父節點
當前提交
013c5ac0fa
共有 2 個文件被更改,包括 21 次插入1 次删除
  1. 1
    1
      roles/monitoring/tasks/monit.yml
  2. 20
    0
      roles/monitoring/templates/etc_monit_monitrc.j2

+ 1
- 1
roles/monitoring/tasks/monit.yml 查看文件

@@ -13,7 +13,7 @@
13 13
     - dependencies
14 14
 
15 15
 - name: Copy monit master config file into place
16
-  copy: src=etc_monit_monitrc dest=/etc/monit/monitrc
16
+  template: src=etc_monit_monitrc.j2 dest=/etc/monit/monitrc
17 17
   notify: restart monit
18 18
 
19 19
 - name: Determine if ZNC is installed

roles/monitoring/files/etc_monit_monitrc → roles/monitoring/templates/etc_monit_monitrc.j2 查看文件

@@ -103,6 +103,21 @@ set mailserver localhost
103 103
 #
104 104
 # set mail-format { from: monit@foo.bar }
105 105
 #
106
+
107
+set mail-format {
108
+     from: monit@{{ domain }}
109
+  subject: monit alert --  $EVENT $SERVICE
110
+  message: $EVENT Service $SERVICE
111
+
112
+    Date:        $DATE
113
+    Action:      $ACTION
114
+    Host:        $HOST
115
+    Description: $DESCRIPTION
116
+
117
+Your faithful employee,
118
+Monit from Sovereign
119
+}
120
+
106 121
 #
107 122
 ## You can set alert recipients whom will receive alerts if/when a
108 123
 ## service defined in this file has errors. Alerts may be restricted on
@@ -112,15 +127,20 @@ set mailserver localhost
112 127
 # set alert manager@foo.bar only on { timeout }  # receive just service-
113 128
 #                                                # timeout alert
114 129
 #
130
+
131
+set alert {{ admin_email }}
132
+
115 133
 #
116 134
 ## Monit has an embedded web server which can be used to view status of
117 135
 ## services monitored and manage services from a web interface. See the
118 136
 ## Monit Wiki if you want to enable SSL for the web server.
119 137
 #
138
+
120 139
 set httpd port 2812 and
121 140
     use address localhost  # only accept connection from localhost
122 141
     allow localhost        # allow localhost to connect to the server and
123 142
     allow admin:monit      # require user 'admin' with password 'monit'
143
+
124 144
 #    allow @monit           # allow users of group 'monit' to connect (rw)
125 145
 #    allow @users readonly  # allow users of group 'users' to connect readonly
126 146
 #

Loading…
取消
儲存