]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - 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
1 { config, pkgs, lib, hostFQDN, emailCheck, ... }:
2 let
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 };
12 in
13 {
14 activatedPlugins = [ "file_date" "mysql" "openldap" "redis" "emails" ];
15 service = [
16 (emailCheck "backup-2" hostFQDN // {
17 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-email"; freshness_threshold = "1350"; };
18 })
19 {
20 passiveInfo = defaultPassiveInfo;
21 service_description = "Size on /backup2 partition";
22 use = "local-service";
23 check_command = ["check_local_disk" "10%" "5%" "/backup2"];
24 }
25 {
26 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-backup"; };
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 {
32 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-backup"; };
33 service_description = "Last backup in /backup2/dilion is not too old";
34 use = "local-service";
35 check_command = ["check_last_file_date" "/backup2/dilion" "14" "backup"];
36 }
37 {
38 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-backup"; };
39 service_description = "Last backup in /backup2/ulminfo is not too old";
40 use = "local-service";
41 check_command = ["check_last_file_date" "/backup2/ulminfo" "14" "backup"];
42 }
43 {
44 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases,webstatus-backup"; };
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 }
49 {
50 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases"; };
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 {
56 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases,webstatus-backup"; };
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 {
62 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases"; };
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 }
67 {
68 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases,webstatus-backup"; };
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 }
73 {
74 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases"; };
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" ''
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
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 {
105 passiveInfo = defaultPassiveInfo // { servicegroups = "webstatus-databases,webstatus-backup"; };
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 }
110 ];
111 }