modules/nixos/monitoring: import hosts from knownHosts
This commit is contained in:
parent
cf9f6100a9
commit
06c99f6ef1
3 changed files with 10 additions and 16 deletions
modules/nixos/monitoring
|
@ -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"
|
||||
]
|
|
@ -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";
|
||||
}
|
||||
];
|
||||
|
|
|
@ -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" ];
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue