From 6af79c5d13ec48b1fd46f9ba07a97a906be2f47e Mon Sep 17 00:00:00 2001 From: Pierre D Date: Fri, 14 Nov 2014 12:18:19 +0100 Subject: [PATCH] Added email alerts to configuration --- README.md | 10 ++++++++++ defaults/main.yml | 8 ++++++++ templates/munin.conf.j2 | 9 +++++++++ 3 files changed, 27 insertions(+) diff --git a/README.md b/README.md index bb8edfd..cfd9c46 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,16 @@ A listing of hosts to which munin will connect and monitor. Each item in the lis See documentation for [Munin Node Definitions](http://munin.readthedocs.org/en/latest/reference/munin.conf.html#node-definitions) for more details as to what values to use here. +You can enable mail alerts by adding : + + munin_alerts: + - { + name: "John Doe", + email: "johndoe@example.com", + subject: "Munin-notification for ${var:group} :: ${var:host}", + level: "warning critical" + } + ## Dependencies None. diff --git a/defaults/main.yml b/defaults/main.yml index 8fe7ca6..d19bc9f 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -34,3 +34,11 @@ munin_hosts: address: "127.0.0.1", extra: ["use_node_name yes"] } + +munin_alerts: [] +# - { +# name: "John Doe", +# email: "johndoe@example.com", +# subject: "Munin-notification for ${var:group} :: ${var:host}", +# level: "warning critical" +# } \ No newline at end of file diff --git a/templates/munin.conf.j2 b/templates/munin.conf.j2 index f35f1ff..9327f92 100644 --- a/templates/munin.conf.j2 +++ b/templates/munin.conf.j2 @@ -74,6 +74,15 @@ max_processes {{ munin_max_processes }} # something changes (OK -> WARNING, CRITICAL -> OK, etc) #contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm #contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm + +{% if munin_alerts %} +{% for contact in munin_alerts %} +contacts {{ contact.name }} +contact.{{ contact.name }}.command mail -s "{{ contact.subject }}" {{ contact.email }} +contact.{{ contact.name }}.always_send {{ contact.level }} +{% endfor %} +{% endif %} + # # For those with Nagios, the following might come in handy. In addition, # the services must be defined in the Nagios server as well.