]>
Commit | Line | Data |
---|---|---|
1 | { config, pkgs, lib, nodes, name, monitoring, ... }: | |
2 | let | |
3 | mlib = monitoring.lib; | |
4 | nodesWithMonitoring = lib.filterAttrs (n: v: (v.config.myServices or {}) ? "monitoring") nodes; | |
5 | in | |
6 | { | |
7 | imports = [ | |
8 | ./monitoring/master.nix | |
9 | ./monitoring/phare.nix | |
10 | ./monitoring/ulminfo-fr.nix | |
11 | ]; | |
12 | myServices.monitoring.activatedPlugins = lib.flatten (lib.mapAttrsToList (_: n: n.config.myServices.monitoring.fromMasterActivatedPlugins) nodesWithMonitoring); | |
13 | myServices.monitoring.objects = lib.mkMerge ( | |
14 | lib.mapAttrsToList (_: n: | |
15 | mlib.toMasterPassiveObject "external-passive-service" 1.5 n.config.myServices.monitoring.objects | |
16 | ) (lib.filterAttrs (n: v: n != name) nodesWithMonitoring) | |
17 | ++ | |
18 | lib.mapAttrsToList (_: n: n.config.myServices.monitoring.fromMasterObjects) nodesWithMonitoring | |
19 | ); | |
20 | myServices.chatonsProperties.hostings.monitoring = { | |
21 | file.datetime = "2022-08-27T16:00:00"; | |
22 | hosting = { | |
23 | name = "Monitoring"; | |
24 | description = "Website and server health monitoring"; | |
25 | website = "https://status.immae.eu"; | |
26 | logo = "https://www.naemon.io/favicon.ico"; | |
27 | status.level = "OK"; | |
28 | status.description = "OK"; | |
29 | registration.load = "OPEN"; | |
30 | install.type = "PACKAGE"; | |
31 | }; | |
32 | software = { | |
33 | name = "naemon"; | |
34 | website = "https://www.naemon.io/"; | |
35 | license.url = "https://github.com/naemon/naemon-core/blob/master/COPYING"; | |
36 | license.name = "GNU General Public License v2.0"; | |
37 | version = config.services.naemon.package.version; | |
38 | source.url = "https://github.com/naemon/naemon-core"; | |
39 | modules = "livestatus,status-engine"; | |
40 | }; | |
41 | }; | |
42 | ||
43 | services.nginx = { | |
44 | virtualHosts."status.immae.eu".locations = { | |
45 | "=/common/immae.cfg" = { | |
46 | alias = pkgs.writeText "immae.cfg" '' | |
47 | # put me for instance in /etc/naemon/module-conf.d/immae.cfg | |
48 | # Make sure that you have include_dir=module-conf.d in | |
49 | # naemon.cfg | |
50 | log_initial_states=1 | |
51 | date_format=iso8601 | |
52 | admin_email=${config.myEnv.monitoring.email} | |
53 | obsess_over_services=1 | |
54 | ocsp_command=notify-master | |
55 | ''; | |
56 | }; | |
57 | "=/common/resource.cfg" = { | |
58 | alias = pkgs.writeText "resource.cfg" '' | |
59 | # Resource.cfg file | |
60 | # Replace this with path to monitoring plugins | |
61 | $USER1$=@@COMMON_PLUGINS@@ | |
62 | # Replace this with a path to scripts from | |
63 | # https://git.immae.eu/cgit/perso/Immae/Config/Nix.git/tree/modules/private/monitoring/plugins | |
64 | $USER2$=@@IMMAE_PLUGINS@@ | |
65 | $USER200$=https://status.immae.eu/ | |
66 | $USER201$=@@TOKEN@@ | |
67 | ''; | |
68 | }; | |
69 | }; | |
70 | }; | |
71 | ||
72 | secrets.keys = lib.mapAttrs' (k: v: lib.nameValuePair "${k}_access_key" { | |
73 | user = "naemon"; | |
74 | group = "naemon"; | |
75 | permissions = "0400"; | |
76 | text = '' | |
77 | export AWS_ACCESS_KEY_ID="${v.accessKeyId}" | |
78 | export AWS_SECRET_ACCESS_KEY="${v.secretAccessKey}" | |
79 | export BASE_URL="${v.remote "immae-eldiron"}" | |
80 | ''; | |
81 | }) config.myEnv.backup.remotes; | |
82 | ||
83 | services.naemon.extraConfig = '' | |
84 | broker_module=${pkgs.naemon-livestatus}/lib/naemon-livestatus/livestatus.so ${config.services.naemon.runDir}/live | |
85 | broker_module=${pkgs.status-engine-module}/lib/status-engine/naemon/statusengine-${pkgs.naemon.status_engine_version}.o use_service_perfdata=1 use_process_data=0 use_system_command_data=0 use_external_command_data=0 use_flapping_data=0 use_program_status_data=0 use_notification_data=0 use_contact_status_data=0 use_contact_notification_data=0 use_event_handler_data=0 use_object_data=0 | |
86 | ''; | |
87 | } |