From da1b36de16afec9f8e0f43ce450ddcf4407920b6 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Mon, 12 Aug 2024 16:05:07 +0200 Subject: [PATCH] dd --- docker-compose/postfix/docker-compose.yml.j2 | 1 + group_vars/munin.yml | 2 ++ roles/mgrote_munin_server/defaults/main.yml | 2 ++ roles/mgrote_munin_server/tasks/main.yml | 34 ------------------- .../mgrote_munin_server/templates/munin.conf | 4 ++- 5 files changed, 8 insertions(+), 35 deletions(-) diff --git a/docker-compose/postfix/docker-compose.yml.j2 b/docker-compose/postfix/docker-compose.yml.j2 index d7c2f394..8cec9634 100644 --- a/docker-compose/postfix/docker-compose.yml.j2 +++ b/docker-compose/postfix/docker-compose.yml.j2 @@ -21,6 +21,7 @@ services: /root@pbs.localdomain/ pbs@mgrote.net /root@pve5.localdomain/ pve5@mgrote.net /no-reply@ubnt.com/ ubiquity@mgrote.net + /mg@munin.localdomain/ munin@mgrote.net # rewrite FROM "nobody@lldap" to "lldap@mgrote.net" # /.*/ würde alle absender adressen ersetzen networks: diff --git a/group_vars/munin.yml b/group_vars/munin.yml index 6c4eb493..55f2ccc9 100644 --- a/group_vars/munin.yml +++ b/group_vars/munin.yml @@ -42,6 +42,8 @@ munin_node_bind_port: "4949" munin_node_allowed_cidrs: [127.0.0.1] ### mgrote_munin_master +munin_enable_alerts: true +munin_alerts_to: info@mgrote.net munin_hosts: - name: "{{ ansible_fqdn }}.mgrote.net" address: "127.0.0.1" diff --git a/roles/mgrote_munin_server/defaults/main.yml b/roles/mgrote_munin_server/defaults/main.yml index 7eaca4f4..028c646e 100644 --- a/roles/mgrote_munin_server/defaults/main.yml +++ b/roles/mgrote_munin_server/defaults/main.yml @@ -25,6 +25,8 @@ munin_server_plugins: - munin_update munin_cron_job: present munin_dbdir: "/var/lib/munin" +munin_enable_alerts: true +munin_alerts_to: nobody@nowhere.com munin_hosts: - name: "{{ ansible_fqdn }}" address: "127.0.0.1" diff --git a/roles/mgrote_munin_server/tasks/main.yml b/roles/mgrote_munin_server/tasks/main.yml index b0910197..50cabf42 100644 --- a/roles/mgrote_munin_server/tasks/main.yml +++ b/roles/mgrote_munin_server/tasks/main.yml @@ -59,40 +59,6 @@ create: true mode: '0644' -# TODO mail config? wie senden? -# COPY munin_mail.conf /etc/munin/munin-conf.d/munin_mail.conf - - -# # configure mail notification -# if [[ -n "$MAILCONTACT" && -n "$MAILSERVER" && -n "$MAILPORT" && -n "$MAILUSER" && -n "$MAILPASSWORD" && -n "$MAILDOMAIN" ]] ; then -# MAILCONTACT=${MAILCONTACT:="contact@domain.test"} -# sed -i "s/mailcontact/$MAILCONTACT/g" /etc/ssmtp/ssmtp.conf -# sed -i "s/mailcontact/$MAILCONTACT/g" /etc/munin/munin-conf.d/munin_mail.conf -# MAILSERVER=${MAILSERVER:="mail.domain.test"} -# sed -i "s/mailserver/$MAILSERVER/g" /etc/ssmtp/ssmtp.conf -# sed -i "s/mailserver/$MAILSERVER/g" /etc/ssmtp/revaliases -# MAILPORT=${MAILPORT:="25"} -# sed -i "s/mailport/$MAILPORT/g" /etc/ssmtp/ssmtp.conf -# sed -i "s/mailport/$MAILPORT/g" /etc/ssmtp/revaliases -# MAILUSER=${MAILUSER:="alert@domain.test"} -# sed -i "s/mailuser/$MAILUSER/g" /etc/ssmtp/ssmtp.conf -# MAILFROM=${MAILFROM:="munin@domain.test"} -# sed -i "s/mailfrom/$MAILFROM/g" /etc/ssmtp/revaliases -# MAILPASSWORD=${MAILPASSWORD:="XXXXXXXXX"} -# sed -i "s/mailpassword/$MAILPASSWORD/g" /etc/ssmtp/ssmtp.conf -# MAILDOMAIN=${MAILDOMAIN:="domain.test"} -# sed -i "s/maildomain/$MAILDOMAIN/g" /etc/ssmtp/ssmtp.conf -# sed -i "s/mailhost/$MAILDOMAIN/g" /etc/ssmtp/ssmtp.conf -# MAILNAME=${MAILNAME:="Munin"} -# sed -i "s/munin application user/$MAILNAME/g" /etc/passwd -# else -# rm /etc/munin/munin-conf.d/munin_mail.conf /etc/ssmtp/ssmtp.conf -# fi - -# cronjoib? timer? TODO - -# sed -i "s/\*\/5/\*\/5/g" /etc/cron.d/munin kommt imho aus paket - - name: check if munin has been run ansible.builtin.stat: path: /var/cache/munin/www/index.html diff --git a/roles/mgrote_munin_server/templates/munin.conf b/roles/mgrote_munin_server/templates/munin.conf index 078a8d94..45571e64 100644 --- a/roles/mgrote_munin_server/templates/munin.conf +++ b/roles/mgrote_munin_server/templates/munin.conf @@ -89,7 +89,9 @@ includedir /etc/munin/munin-conf.d # Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime # something changes (OK -> WARNING, CRITICAL -> OK, etc) -#contact.someuser.command mail -s "Munin ${var:worst}: ${var:group}::${var:host}::${var:plugin}" somejuser@fnord.comm +{% if munin_enable_alerts is sameas true %} +#contact.someuser.command mail -s "Munin ${var:worst}: ${var:group}::${var:host}::${var:plugin}" {{ munin_alerts_to }} +{% endif %} #contact.anotheruser.command mail -s "Munin ${var:worst}: ${var:group}::${var:host}::${var:plugin}" anotheruser@blibb.comm # # For those with Nagios, the following might come in handy. In addition,