]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/monitoring/objects_backup-2.nix
Refactor monitoring to avoid useless resources in each machine
[perso/Immae/Config/Nix.git] / modules / private / monitoring / objects_backup-2.nix
CommitLineData
ef0a9217 1{ config, pkgs, lib, hostFQDN, emailCheck, ... }:
e820134d
IB
2let
3 defaultPassiveInfo = {
4 filter = lib.attrsets.filterAttrs
5 (k: v: builtins.elem k ["service_description"] || builtins.substring 0 1 k == "_");
6 use = "external-passive-service";
7 freshness_threshold = "450";
8 retry_interval = "1";
9 servicegroups = "webstatus-resources";
10 host_name = hostFQDN;
11 };
12in
eb071dd4 13{
acab8301 14 activatedPlugins = [ "file_date" "mysql" "openldap" "redis" "emails" ];
eb071dd4 15 service = [
ef0a9217
IB
16 (emailCheck "backup-2" hostFQDN // {
17 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-email"; freshness_threshold = "1350"; };
18 })
eb071dd4 19 {
e820134d 20 passiveInfo = defaultPassiveInfo;
eb071dd4
IB
21 service_description = "Size on /backup2 partition";
22 use = "local-service";
23 check_command = ["check_local_disk" "10%" "5%" "/backup2"];
24 }
25 {
e820134d 26 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-backup"; };
eb071dd4
IB
27 service_description = "Last backup in /backup2/phare is not too old";
28 use = "local-service";
29 check_command = ["check_last_file_date" "/backup2/phare" "14" "backup"];
30 }
31 {
e820134d 32 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-backup"; };
a1a4a72e 33 service_description = "Last backup in /backup2/dilion is not too old";
eb071dd4 34 use = "local-service";
a1a4a72e 35 check_command = ["check_last_file_date" "/backup2/dilion" "14" "backup"];
eb071dd4
IB
36 }
37 {
e820134d 38 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-backup"; };
791d00e6 39 service_description = "Last backup in /backup2/ulminfo is not too old";
eb071dd4 40 use = "local-service";
791d00e6 41 check_command = ["check_last_file_date" "/backup2/ulminfo" "14" "backup"];
eb071dd4
IB
42 }
43 {
e820134d 44 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases,webstatus-backup"; };
eb071dd4
IB
45 service_description = "Last postgresql dump in /backup2/eldiron/postgresql_backup is not too old";
46 use = "local-service";
47 check_command = ["check_last_file_date" "/backup2/eldiron/postgresql_backup" "7" "postgres"];
48 }
6015a3b5 49 {
e820134d 50 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases"; };
6015a3b5
IB
51 service_description = "Redis replication for eldiron is up to date";
52 use = "local-service";
53 check_command = ["check_redis_replication" "/run/redis_eldiron/redis.sock"];
54 }
55 {
e820134d 56 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases,webstatus-backup"; };
6015a3b5
IB
57 service_description = "Last redis dump in /backup2/eldiron/redis_backup is not too old";
58 use = "local-service";
59 check_command = ["check_last_file_date" "/backup2/eldiron/redis_backup" "7" "redis"];
60 }
61 {
e820134d 62 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases"; };
6015a3b5
IB
63 service_description = "Mysql replication for eldiron is up to date";
64 use = "local-service";
65 check_command = ["check_mysql_replication" "/run/mysqld_eldiron/mysqld.sock" "/var/secrets/mysql_replication/eldiron/client"];
66 }
9f6a7862 67 {
e820134d 68 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases,webstatus-backup"; };
9f6a7862
IB
69 service_description = "Last mysql dump in /backup2/eldiron/mysql_backup is not too old";
70 use = "local-service";
71 check_command = ["check_last_file_date" "/backup2/eldiron/mysql_backup" "7" "mysql"];
72 }
16b80abd 73 {
e820134d 74 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases"; };
16b80abd
IB
75 service_description = "Openldap replication for eldiron is up to date";
76 use = "local-service";
77 check_command = let
78 name = "eldiron";
79 hcfg = config.myServices.databasesReplication.openldap.hosts.eldiron;
80 base = config.myServices.databasesReplication.openldap.base;
81 eldiron_schemas = pkgs.callPackage ../databases/openldap/eldiron_schemas.nix {};
82 ldapConfig = pkgs.writeText "slapd.conf" ''
5400b9b6
IB
83 include ${pkgs.openldap}/etc/schema/core.schema
84 include ${pkgs.openldap}/etc/schema/cosine.schema
85 include ${pkgs.openldap}/etc/schema/inetorgperson.schema
86 include ${pkgs.openldap}/etc/schema/nis.schema
16b80abd
IB
87 ${eldiron_schemas}
88 moduleload back_hdb
89 backend hdb
90 database hdb
91
92 suffix "${hcfg.base}"
93 directory ${base}/${name}/openldap
94 '';
95 in [
96 "check_openldap_replication"
97 hcfg.url
98 hcfg.dn
99 "${config.secrets.location}/openldap_replication/eldiron/replication_password"
100 hcfg.base
101 ldapConfig
102 ];
103 }
104 {
e820134d 105 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases,webstatus-backup"; };
16b80abd
IB
106 service_description = "Last openldap dump in /backup2/eldiron/openldap_backup is not too old";
107 use = "local-service";
108 check_command = ["check_last_file_date" "/backup2/eldiron/openldap_backup" "7" "openldap"];
109 }
eb071dd4
IB
110 ];
111}