modules/nixos/monitoring: import hosts from knownHosts

This commit is contained in:
zowoq 2024-11-03 12:16:44 +10:00
parent cf9f6100a9
commit 06c99f6ef1
3 changed files with 10 additions and 16 deletions
modules/nixos/monitoring

View file

@ -1,9 +0,0 @@
[
"build01.nix-community.org"
"build02.nix-community.org"
"build03.nix-community.org"
"build04.nix-community.org"
"darwin01.nix-community.org"
"darwin02.nix-community.org"
#"web02.nix-community.org"
]

View file

@ -1,4 +1,4 @@
{ pkgs, ... }:
{ inputs, pkgs, ... }:
{
systemd.services.prometheus.after = pkgs.lib.mkForce [ "network-online.target" ];
systemd.services.prometheus.wants = [ "network-online.target" ];
@ -19,11 +19,13 @@
metrics_path = "/metrics";
static_configs =
let
hosts = import ./hosts.nix;
hosts = (import "${inputs.self}/modules/shared/known-hosts.nix").programs.ssh.knownHosts;
in
[
{
targets = map (host: "${host}:9273") hosts ++ [ "localhost:9273" ];
targets = builtins.concatMap (host: map (name: "${name}:9273") host.hostNames) (
builtins.attrValues hosts
);
labels.org = "nix-community";
}
];

View file

@ -1,3 +1,4 @@
{ inputs, ... }:
{
services.telegraf.extraConfig.inputs = {
http_response = [
@ -28,17 +29,17 @@
];
net_response =
let
hosts = import ./hosts.nix;
hosts = (import "${inputs.self}/modules/shared/known-hosts.nix").programs.ssh.knownHosts;
in
map (host: {
protocol = "tcp";
address = "${host}:22";
address = "${toString host.hostNames}:22";
send = "SSH-2.0-Telegraf";
expect = "SSH-2.0";
tags.host = host;
tags.host = toString host.hostNames;
tags.org = "nix-community";
timeout = "10s";
}) hosts;
}) (builtins.attrValues hosts);
prometheus.urls = [ "https://events.ofborg.org/prometheus.php" ];
};
}