]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/private/system/monitoring-1.nix
Add netdata configuration
[perso/Immae/Config/Nix.git] / modules / private / system / monitoring-1.nix
index 14604780e51e50356882333815fa395991b791a0..188162ac99605efff4e04725ee6cfb63778a9d98 100644 (file)
@@ -1,21 +1,15 @@
 { privateFiles }:
 { config, pkgs, resources, ... }:
 {
+  deployment = {
+    targetUser = "root";
+    targetHost = config.hostEnv.ips.main.ip4;
+    substituteOnDestination = true;
+  };
   boot.kernelPackages = pkgs.linuxPackages_latest;
   myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
-  hostEnv.FQDN = "monitoring-1.v.immae.eu";
-
-  imports = builtins.attrValues (import ../..);
 
-  deployment = {
-    targetEnv = "hetznerCloud";
-    hetznerCloud = {
-      authToken = config.myEnv.hetznerCloud.authToken;
-      datacenter = "hel1-dc2";
-      location  ="hel1";
-      serverType = "cx11";
-    };
-  };
+  imports = [ <nixpkgs/nixos/modules/profiles/qemu-guest.nix> ] ++ builtins.attrValues (import ../..);
 
   myServices.monitoring.enable = true;
   myServices.monitoring.master = true;
     firewall.enable = true;
     interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
       (n: ips: { address = ips.ip4; prefixLength = 32; })
-      (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.myEnv.servers.monitoring-1.ips);
+      (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
     interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
       (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
-      config.myEnv.servers.monitoring-1.ips);
+      config.hostEnv.ips);
     defaultGateway6 = { address = "fe80::1"; interface = "ens3"; };
   };
+  boot.loader.grub.device = "nodev";
+  fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };
   myServices.mailRelay.enable = true;
 
+  security.pki.certificateFiles = [
+    (pkgs.fetchurl {
+      url = "http://downloads.e.eriomem.net/eriomemca.pem";
+      sha256 = "1ixx4c6j3m26j8dp9a3dkvxc80v1nr5aqgmawwgs06bskasqkvvh";
+    })
+  ];
+
+  services.netdata.enable = true;
+  services.netdata.config.web."allow dashboard from" = "localhost";
+  services.netdata.config.web."allow badges from" = "*";
+  services.netdata.config.web."allow streaming from" = "*";
+  services.netdata.config.web."allow netdata.conf from" = "fd*";
+  services.netdata.config.web."allow management from" = "fd*";
+  networking.firewall.allowedTCPPorts = [ 19999 ];
+  environment.etc."netdata/stream.conf".text = builtins.concatStringsSep "\n" (pkgs.lib.mapAttrsToList (_: key: ''
+    [${key}]
+        enabled = yes
+        default history = 3600
+        default memory = ram
+        health enabled by default = auto
+  '') config.myEnv.monitoring.netdata_keys);
   # This value determines the NixOS release with which your system is
   # to be compatible, in order to avoid breaking some software such as
   # database servers. You should change this only after NixOS release
   # notes say you should.
   # https://nixos.org/nixos/manual/release-notes.html
-  system.stateVersion = "19.03"; # Did you read the comment?
+  system.stateVersion = "20.03"; # Did you read the comment?
 }