diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/private/environment.nix | 4 | ||||
-rw-r--r-- | modules/private/mail/postfix.nix | 9 | ||||
-rw-r--r-- | modules/private/monitoring/objects_backup-2.nix | 5 | ||||
-rw-r--r-- | modules/private/monitoring/objects_monitoring-1.nix | 4 | ||||
-rwxr-xr-x | modules/private/monitoring/plugins/check_emails | 2 |
5 files changed, 16 insertions, 8 deletions
diff --git a/modules/private/environment.nix b/modules/private/environment.nix index ffb61c5..c4c32c8 100644 --- a/modules/private/environment.nix +++ b/modules/private/environment.nix | |||
@@ -493,8 +493,8 @@ in | |||
493 | port = mkOption { type = nullOr str; default = null; description = "Port to connect to ssh"; }; | 493 | port = mkOption { type = nullOr str; default = null; description = "Port to connect to ssh"; }; |
494 | login = mkOption { type = nullOr str; default = null; description = "Login to connect to ssh"; }; | 494 | login = mkOption { type = nullOr str; default = null; description = "Login to connect to ssh"; }; |
495 | targets = mkOption { type = listOf str; description = "Hosts to send E-mails to"; }; | 495 | targets = mkOption { type = listOf str; description = "Hosts to send E-mails to"; }; |
496 | mail_address = mkOption { type = str; description = "E-mail recipient part to send e-mail to"; }; | 496 | mail_address = mkOption { type = nullOr str; default = null; description = "E-mail recipient part to send e-mail to"; }; |
497 | mail_domain = mkOption { type = str; description = "E-mail domain part to send e-mail to"; }; | 497 | mail_domain = mkOption { type = nullOr str; default = null; description = "E-mail domain part to send e-mail to"; }; |
498 | }; | 498 | }; |
499 | }); | 499 | }); |
500 | }; | 500 | }; |
diff --git a/modules/private/mail/postfix.nix b/modules/private/mail/postfix.nix index 51f4de7..2af1849 100644 --- a/modules/private/mail/postfix.nix +++ b/modules/private/mail/postfix.nix | |||
@@ -267,9 +267,12 @@ | |||
267 | ); | 267 | ); |
268 | }; | 268 | }; |
269 | sasl_access = { | 269 | sasl_access = { |
270 | host_sender_login = pkgs.writeText "host-sender-login" | 270 | host_sender_login = with lib.attrsets; let |
271 | (builtins.concatStringsSep "\n" (lib.flatten (lib.attrsets.mapAttrsToList | 271 | addresses = zipAttrs (lib.flatten (mapAttrsToList |
272 | (n: v: (map (e: "${e} ${n}@immae.eu") v.emails)) config.myEnv.servers))); | 272 | (n: v: (map (e: { "${e}" = "${n}@immae.eu"; }) v.emails)) config.myEnv.servers)); |
273 | joined = builtins.concatStringsSep ","; | ||
274 | in pkgs.writeText "host-sender-login" | ||
275 | (builtins.concatStringsSep "\n" (mapAttrsToList (n: v: "${n} ${joined v}") addresses)); | ||
273 | host_dummy_mailboxes = pkgs.writeText "host-virtual-mailbox" | 276 | host_dummy_mailboxes = pkgs.writeText "host-virtual-mailbox" |
274 | (builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: "${n}@immae.eu dummy") nodes)); | 277 | (builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: "${n}@immae.eu dummy") nodes)); |
275 | }; | 278 | }; |
diff --git a/modules/private/monitoring/objects_backup-2.nix b/modules/private/monitoring/objects_backup-2.nix index 52289dd..927cc25 100644 --- a/modules/private/monitoring/objects_backup-2.nix +++ b/modules/private/monitoring/objects_backup-2.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { config, pkgs, lib, hostFQDN, ... }: | 1 | { config, pkgs, lib, hostFQDN, emailCheck, ... }: |
2 | let | 2 | let |
3 | defaultPassiveInfo = { | 3 | defaultPassiveInfo = { |
4 | filter = lib.attrsets.filterAttrs | 4 | filter = lib.attrsets.filterAttrs |
@@ -12,6 +12,9 @@ let | |||
12 | in | 12 | in |
13 | { | 13 | { |
14 | service = [ | 14 | service = [ |
15 | (emailCheck "backup-2" hostFQDN // { | ||
16 | passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-email"; freshness_threshold = "1350"; }; | ||
17 | }) | ||
15 | { | 18 | { |
16 | passiveInfo = defaultPassiveInfo; | 19 | passiveInfo = defaultPassiveInfo; |
17 | service_description = "Size on /backup2 partition"; | 20 | service_description = "Size on /backup2 partition"; |
diff --git a/modules/private/monitoring/objects_monitoring-1.nix b/modules/private/monitoring/objects_monitoring-1.nix index f69d3ff..3200d5c 100644 --- a/modules/private/monitoring/objects_monitoring-1.nix +++ b/modules/private/monitoring/objects_monitoring-1.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { config, pkgs, ... }: | 1 | { config, pkgs, hostFQDN, emailCheck, ... }: |
2 | { | 2 | { |
3 | host = { | 3 | host = { |
4 | # Dummy host for testing | 4 | # Dummy host for testing |
@@ -22,6 +22,8 @@ | |||
22 | # check_command = "check_critical"; | 22 | # check_command = "check_critical"; |
23 | # } | 23 | # } |
24 | 24 | ||
25 | (emailCheck "monitoring-1" hostFQDN) | ||
26 | |||
25 | { | 27 | { |
26 | service_description = "ftp has access to database for authentication"; | 28 | service_description = "ftp has access to database for authentication"; |
27 | host_name = "eldiron.immae.eu"; | 29 | host_name = "eldiron.immae.eu"; |
diff --git a/modules/private/monitoring/plugins/check_emails b/modules/private/monitoring/plugins/check_emails index 0ee3e4e..5a8453e 100755 --- a/modules/private/monitoring/plugins/check_emails +++ b/modules/private/monitoring/plugins/check_emails | |||
@@ -37,7 +37,7 @@ my @emails_to_expect = split(/,/, $opts{'f'}); | |||
37 | 37 | ||
38 | my $cmd_result; | 38 | my $cmd_result; |
39 | if ($local_directory ne '') { | 39 | if ($local_directory ne '') { |
40 | if (! -d $local_directory) { | 40 | if (@emails_to_expect and ! -d $local_directory) { |
41 | print "Emails $host UNKNOWN - Could not find local directory"; | 41 | print "Emails $host UNKNOWN - Could not find local directory"; |
42 | exit($STATE_UNKNOWN); | 42 | exit($STATE_UNKNOWN); |
43 | } | 43 | } |