diff --git a/hosts/fra1-b/configuration.nix b/hosts/fra1-b/configuration.nix index fdbb465..213cd7b 100644 --- a/hosts/fra1-b/configuration.nix +++ b/hosts/fra1-b/configuration.nix @@ -76,6 +76,7 @@ in services = { node_exporter.enable = true; + ping_exporter.enable = true; tailscale.enable = true; ssh8022.server = { diff --git a/hosts/fwminex/configuration.nix b/hosts/fwminex/configuration.nix index 8f1bb23..a26101d 100644 --- a/hosts/fwminex/configuration.nix +++ b/hosts/fwminex/configuration.nix @@ -342,39 +342,23 @@ in evaluation_interval = "1m"; }; - exporters.ping = { - enable = true; - settings = { - options.disableIPv6 = true; - ping = { - interval = "1s"; - timeout = "5s"; - history-size = 10; - }; - targets = [ - "1.1.1.1" - "8.8.4.4" - "fb.com" - "rrt.lt" - "kam.lt" - "lrs.lt" - "15min.lt" - - "fra1-b.jakstys.lt" - myData.hosts."fra1-b.servers.jakst".jakstIP - ]; - }; - }; - scrapeConfigs = - let - port = builtins.toString myData.ports.exporters.node; - in [ { job_name = "ping"; static_configs = [ - { targets = [ "127.0.0.1:${toString config.services.prometheus.exporters.ping.port}" ]; } + ( + let + port = toString config.services.prometheus.exporters.ping.port; + in + { + targets = [ + "127.0.0.1:${port}" + "${myData.hosts."fra1-b.servers.jakst".jakstIP}:${port}" + "${myData.hosts."vno1-gdrx.motiejus.jakst".jakstIP}:${port}" + ]; + } + ) ]; } { @@ -401,19 +385,23 @@ in static_configs = [ { targets = [ "${myData.hosts."vno1-vinc.vincentas.jakst".jakstIP}:9100" ]; } ]; } ] - ++ - map - (s: { + ++ map + ( + let + port = builtins.toString myData.ports.exporters.node; + in + s: { job_name = s; static_configs = [ { targets = [ "${myData.hosts.${s}.jakstIP}:${port}" ]; } ]; - }) - [ - "fra1-b.servers.jakst" - "fwminex.servers.jakst" - "mtworx.motiejus.jakst" - "vno3-rp3b.servers.jakst" - "vno1-gdrx.motiejus.jakst" - ]; + } + ) + [ + "fra1-b.servers.jakst" + "fwminex.servers.jakst" + "mtworx.motiejus.jakst" + "vno3-rp3b.servers.jakst" + "vno1-gdrx.motiejus.jakst" + ]; }; }; @@ -441,6 +429,13 @@ in hass.enable = true; syncthing-relay.enable = true; + ping_exporter.enable = true; + + node_exporter = { + enable = true; + extraSubnets = [ myData.subnets.vno1.cidr ]; + }; + ssh8022.server = { enable = true; keyfile = config.age.secrets.ssh8022-server.path; @@ -596,11 +591,6 @@ in sshKey = "/etc/ssh/ssh_host_ed25519_key"; }; - node_exporter = { - enable = true; - extraSubnets = [ myData.subnets.vno1.cidr ]; - }; - deployerbot = { main = { enable = true; diff --git a/hosts/vno1-gdrx/configuration.nix b/hosts/vno1-gdrx/configuration.nix index 18e2a7f..a3e9379 100644 --- a/hosts/vno1-gdrx/configuration.nix +++ b/hosts/vno1-gdrx/configuration.nix @@ -89,6 +89,13 @@ in }; services = { + ping_exporter.enable = true; + + node_exporter = { + enable = true; + extraSubnets = [ myData.subnets.vno1.cidr ]; + }; + ssh8022.client = { enable = true; keyfile = config.age.secrets.ssh8022-client.path; @@ -142,11 +149,6 @@ in maxJobs = 2; }; - node_exporter = { - enable = true; - extraSubnets = [ myData.subnets.vno1.cidr ]; - }; - deployerbot = { follower = { publicKeys = [ myData.hosts."fwminex.servers.jakst".publicKey ]; diff --git a/modules/services/default.nix b/modules/services/default.nix index 5b82dd2..8d667f6 100644 --- a/modules/services/default.nix +++ b/modules/services/default.nix @@ -15,6 +15,7 @@ ./minidlna ./node_exporter ./nsd-acme + ./ping_exporter ./photoprism ./postfix ./remote-builder diff --git a/modules/services/ping_exporter/default.nix b/modules/services/ping_exporter/default.nix new file mode 100644 index 0000000..b21d493 --- /dev/null +++ b/modules/services/ping_exporter/default.nix @@ -0,0 +1,47 @@ +{ + config, + lib, + myData, + ... +}: +let + cfg = config.mj.services.ping_exporter; +in +{ + options.mj.services.ping_exporter = with lib.types; { + enable = lib.mkEnableOption "Enable ping_exporter"; + }; + + config = lib.mkIf cfg.enable { + services.prometheus.exporters.ping = { + enable = true; + settings = { + options.disableIPv6 = true; + ping = { + interval = "1s"; + timeout = "5s"; + history-size = 10; + }; + targets = [ + "1.1.1.1" + "8.8.4.4" + "fb.com" + "rrt.lt" + "kam.lt" + "lrs.lt" + "15min.lt" + + "fra1-b.jakstys.lt" + myData.hosts."fra1-b.servers.jakst".jakstIP + ]; + }; + }; + + mj.services.friendlyport.ports = [ + { + subnets = [ myData.subnets.tailscale.cidr ]; + tcp = [ config.services.prometheus.exporters.ping.port ]; + } + ]; + }; +}