From f8fb5fa4ff2d5ca25ca124657a1847f029ced31b Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Thu, 17 Aug 2023 18:55:40 +0200 Subject: [PATCH] Monitor power from other nodes via LAN --- m/hut/ipmi.yml | 13 ++++++++++ m/hut/monitoring.nix | 62 +++++++++++++++++++++++++++++++++++++++++--- m/hut/targets.yml | 11 ++++++++ 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 m/hut/ipmi.yml create mode 100644 m/hut/targets.yml diff --git a/m/hut/ipmi.yml b/m/hut/ipmi.yml new file mode 100644 index 0000000..0d68a53 --- /dev/null +++ b/m/hut/ipmi.yml @@ -0,0 +1,13 @@ +modules: + default: + collectors: + - bmc + - ipmi + - chassis + + lan: + collectors: + - ipmi + - chassis + user: "" + pass: "" diff --git a/m/hut/monitoring.nix b/m/hut/monitoring.nix index d68fe3c..a00fb9b 100644 --- a/m/hut/monitoring.nix +++ b/m/hut/monitoring.nix @@ -42,9 +42,13 @@ services.prometheus = { exporters = { - ipmi.enable = true; - ipmi.group = "root"; - ipmi.user = "root"; + ipmi = { + enable = true; + group = "root"; + user = "root"; + configFile = ./ipmi.yml; + #extraFlags = [ "--log.level=debug" ]; + }; node = { enable = true; enabledCollectors = [ "systemd" ]; @@ -66,6 +70,58 @@ ]; }]; } + { + # Scrape the IPMI info of the hosts remotely via LAN + job_name = "ipmi-lan"; + scrape_interval = "1m"; + scrape_timeout = "30s"; + metrics_path = "/ipmi"; + scheme = "http"; + relabel_configs = [ + { + # Takes the address and sets it in the "target=" URL parameter + source_labels = [ "__address__" ]; + separator = ";"; + regex = "(.*)(:80)?"; + target_label = "__param_target"; + replacement = "\${1}"; + action = "replace"; + } + { + # Sets the "instance" label with the remote host we are querying + source_labels = [ "__param_target" ]; + separator = ";"; + regex = "(.*)"; + target_label = "instance"; + replacement = "\${1}"; + action = "replace"; + } + { + # Sets the fixed "module=lan" URL param + separator = ";"; + regex = "(.*)"; + target_label = "__param_module"; + replacement = "lan"; + action = "replace"; + } + { + # Sets the target to query as the localhost IPMI exporter + separator = ";"; + regex = ".*"; + target_label = "__address__"; + replacement = "127.0.0.1:9290"; + action = "replace"; + } + ]; + + # Load the list of targets from another file + file_sd_configs = [ + { + files = [ "${./targets.yml}" ]; + refresh_interval = "30s"; + } + ]; + } ]; }; } diff --git a/m/hut/targets.yml b/m/hut/targets.yml new file mode 100644 index 0000000..2cecd66 --- /dev/null +++ b/m/hut/targets.yml @@ -0,0 +1,11 @@ +- targets: + - 10.0.40.101 + - 10.0.40.102 + - 10.0.40.103 + - 10.0.40.104 + - 10.0.40.105 + - 10.0.40.106 + - 10.0.40.107 + - 10.0.40.108 + labels: + job: ipmi-lan