mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-08-25 20:43:56 +02:00
feat(monitoring): collect homelab UPS metrics
This commit is contained in:
@@ -71,6 +71,22 @@
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
job_name = "nut-exporter-homelab-ups";
|
||||
scrape_interval = "30s";
|
||||
metrics_path = "/ups_metrics";
|
||||
params.ups = [ "homelab" ];
|
||||
static_configs = [
|
||||
{
|
||||
targets = [ "${myvars.networking.hostsAddr.kubevirt-shushou.ipv4}:9199" ];
|
||||
labels.type = "app";
|
||||
labels.app = "nut";
|
||||
labels.host = "kubevirt-shushou";
|
||||
labels.env = "homelab";
|
||||
labels.cluster = "homelab";
|
||||
}
|
||||
];
|
||||
}
|
||||
{
|
||||
job_name = "postgres-exporter";
|
||||
scrape_interval = "30s";
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
{ myvars, ... }:
|
||||
let
|
||||
hostAddress = myvars.networking.hostsAddr.kubevirt-shushou.ipv4;
|
||||
in
|
||||
{
|
||||
power.ups = {
|
||||
enable = true;
|
||||
mode = "standalone";
|
||||
|
||||
# Metrics only. Coordinated shutdown of all homelab hosts is a separate feature.
|
||||
upsmon = {
|
||||
enable = false;
|
||||
settings.POWERDOWNFLAG = null;
|
||||
};
|
||||
|
||||
upsd.listen = [
|
||||
{
|
||||
address = "127.0.0.1";
|
||||
port = 3493;
|
||||
}
|
||||
];
|
||||
|
||||
ups.homelab = {
|
||||
driver = "nutdrv_qx";
|
||||
port = "auto";
|
||||
description = "Homelab UPS";
|
||||
directives = [
|
||||
"vendorid = 0665"
|
||||
"productid = 5161"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
services.prometheus.exporters.nut = {
|
||||
enable = true;
|
||||
listenAddress = hostAddress;
|
||||
port = 9199;
|
||||
nutServer = "127.0.0.1";
|
||||
|
||||
# The NixOS module omits --nut.vars_enable when nutVariables is empty, but the exporter needs
|
||||
# an explicitly empty value to export every numeric NUT variable.
|
||||
extraFlags = [ "--nut.vars_enable=" ];
|
||||
};
|
||||
|
||||
systemd.services.prometheus-nut-exporter = {
|
||||
after = [
|
||||
"upsd.service"
|
||||
"upsdrv.service"
|
||||
];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user