浏览代码

Support multiple monit alert mails, for eg. pushover.

Thomas Buck 5 年前
父节点
当前提交
aa6a5e90e9
共有 3 个文件被更改,包括 14 次插入11 次删除
  1. 4
    0
      group_vars/sovereign
  2. 4
    0
      roles/monitoring/defaults/main.yml
  3. 6
    11
      roles/monitoring/templates/etc_monit_monitrc.j2

+ 4
- 0
group_vars/sovereign 查看文件

@@ -46,6 +46,10 @@ irc_ident: (required)
46 46
 irc_realname: (required)
47 47
 irc_quitmsg: (required)
48 48
 
49
+monit_alert_emails:
50
+  - "{{ admin_email }}"
51
+#  - "PUSHOVER_KEY@pomail.net"
52
+
49 53
 # openvpn
50 54
 openvpn_clients:
51 55
   - laptop

+ 4
- 0
roles/monitoring/defaults/main.yml 查看文件

@@ -6,5 +6,9 @@ secret: '{{ secret_root + "/" + secret_name }}'
6 6
 monit_admin_username: "{{ main_user_name }}"
7 7
 monit_admin_password: "{{ lookup('password', secret + '/' + 'monit_admin_password length=16 chars=hexdigits') }}"
8 8
 
9
+# could be used for example with the pushover.net e-mail notification API
10
+monit_alert_emails:
11
+  - "{{ admin_email }}"
12
+
9 13
 monit_page_public: 1
10 14
 monit_subdomain: status

+ 6
- 11
roles/monitoring/templates/etc_monit_monitrc.j2 查看文件

@@ -106,16 +106,9 @@ set mailserver localhost
106 106
 
107 107
 set mail-format {
108 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
109
+  subject: monit alert $HOST
110
+  message: $EVENT $SERVICE
111
+$DESCRIPTION
119 112
 }
120 113
 
121 114
 #
@@ -128,7 +121,9 @@ Monit from Sovereign
128 121
 #                                                # timeout alert
129 122
 #
130 123
 
131
-set alert {{ admin_email }}
124
+{% for mail in monit_alert_emails %}
125
+set alert {{ mail }}
126
+{% endfor %}
132 127
 
133 128
 #
134 129
 ## Monit has an embedded web server which can be used to view status of

正在加载...
取消
保存