stats: reduce mkMerge usage
This commit is contained in:
parent
0221f34859
commit
47541c5f2b
|
@ -7,6 +7,7 @@ let
|
|||
!config.boot.isContainer &&
|
||||
!(config ? microvm);
|
||||
|
||||
nginxStatusPort = 9100;
|
||||
in
|
||||
{
|
||||
options.c3d2.hq.statistics = {
|
||||
|
@ -16,50 +17,48 @@ in
|
|||
config = {
|
||||
networking.firewall.allowedTCPPorts = [ 9100 ];
|
||||
|
||||
services = lib.mkMerge [
|
||||
(let
|
||||
nginxStatusPort = 9100;
|
||||
in {
|
||||
collectd = lib.mkIf cfg.enable {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
FQDNLookup false
|
||||
Interval 10
|
||||
services = {
|
||||
collectd = lib.mkIf cfg.enable {
|
||||
enable = true;
|
||||
extraConfig = ''
|
||||
FQDNLookup false
|
||||
Interval 10
|
||||
'';
|
||||
buildMinimalPackage = true;
|
||||
plugins = {
|
||||
logfile = ''
|
||||
LogLevel info
|
||||
File STDOUT
|
||||
'';
|
||||
network = ''
|
||||
Server "grafana.serv.zentralwerk.org" "25826"
|
||||
'';
|
||||
memory = "";
|
||||
processes = "";
|
||||
disk = "";
|
||||
df = "";
|
||||
cpu = "";
|
||||
entropy = "";
|
||||
load = "";
|
||||
swap = "";
|
||||
cgroups = "";
|
||||
vmem = "";
|
||||
interface = "";
|
||||
} // lib.optionalAttrs isMetal {
|
||||
sensors = "";
|
||||
cpufreq = "";
|
||||
irq = "";
|
||||
ipmi = "";
|
||||
thermal = "";
|
||||
} // lib.optionalAttrs config.services.nginx.enable {
|
||||
nginx = ''
|
||||
URL "http://localhost:${toString nginxStatusPort}/nginx_status"
|
||||
'';
|
||||
buildMinimalPackage = true;
|
||||
plugins = {
|
||||
logfile = ''
|
||||
LogLevel info
|
||||
File STDOUT
|
||||
'';
|
||||
network = ''
|
||||
Server "grafana.serv.zentralwerk.org" "25826"
|
||||
'';
|
||||
memory = "";
|
||||
processes = "";
|
||||
disk = "";
|
||||
df = "";
|
||||
cpu = "";
|
||||
entropy = "";
|
||||
load = "";
|
||||
swap = "";
|
||||
cgroups = "";
|
||||
vmem = "";
|
||||
interface = "";
|
||||
} // lib.optionalAttrs isMetal {
|
||||
sensors = "";
|
||||
cpufreq = "";
|
||||
irq = "";
|
||||
ipmi = "";
|
||||
thermal = "";
|
||||
} // lib.optionalAttrs config.services.nginx.enable {
|
||||
nginx = ''
|
||||
URL "http://localhost:${toString nginxStatusPort}/nginx_status"
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nginx = lib.mkIf config.services.nginx.enable {
|
||||
nginx = lib.mkMerge [
|
||||
(lib.mkIf config.services.nginx.enable {
|
||||
virtualHosts.localhost = {
|
||||
listen = [
|
||||
{ addr = "127.0.0.1"; port = nginxStatusPort; }
|
||||
|
@ -74,36 +73,30 @@ in
|
|||
deny all;
|
||||
'';
|
||||
};
|
||||
};
|
||||
})
|
||||
})
|
||||
|
||||
(lib.mkIf (pkgs.system != "riscv64-linux") {
|
||||
nginx = {
|
||||
(lib.mkIf (pkgs.system != "riscv64-linux") {
|
||||
enable = true;
|
||||
virtualHosts."_" = {
|
||||
listen =
|
||||
let
|
||||
port = 9100;
|
||||
in
|
||||
[
|
||||
{ addr = "0.0.0.0"; inherit port; }
|
||||
{ addr = "[::]"; inherit port; }
|
||||
];
|
||||
listen = let port = 9100; in [
|
||||
{ addr = "0.0.0.0"; inherit port; }
|
||||
{ addr = "[::]"; inherit port; }
|
||||
];
|
||||
locations."/metrics" = {
|
||||
proxyPass = "http://127.0.0.1:${toString config.services.prometheus.exporters.node.port}/metrics";
|
||||
extraConfig = libC.hqNetworkOnly;
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
prometheus.exporters.node = {
|
||||
enable = true;
|
||||
enabledCollectors = [ "ethtool" "systemd" ];
|
||||
listenAddress = "127.0.0.1";
|
||||
openFirewall = true;
|
||||
port = 9101;
|
||||
};
|
||||
})
|
||||
];
|
||||
prometheus.exporters.node = lib.mkIf (pkgs.system != "riscv64-linux") {
|
||||
enable = true;
|
||||
enabledCollectors = [ "ethtool" "systemd" ];
|
||||
listenAddress = "127.0.0.1";
|
||||
openFirewall = true;
|
||||
port = 9101;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue