lib: break default.nix into stats.nix, add nginx_status
This commit is contained in:
parent
fcea4078cf
commit
867b6e4040
|
@ -27,7 +27,10 @@ let
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
imports = [ ./users ];
|
imports = [
|
||||||
|
./users
|
||||||
|
./stats.nix
|
||||||
|
];
|
||||||
|
|
||||||
options.c3d2 = with lib;
|
options.c3d2 = with lib;
|
||||||
with lib.types; {
|
with lib.types; {
|
||||||
|
@ -77,8 +80,6 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
statistics = { enable = mkEnableOption "statistics collection"; };
|
|
||||||
|
|
||||||
enableBinaryCache = mkOption {
|
enableBinaryCache = mkOption {
|
||||||
type = bool;
|
type = bool;
|
||||||
default = cfg.isInHq;
|
default = cfg.isInHq;
|
||||||
|
@ -241,35 +242,6 @@ in {
|
||||||
keyedHosts = filter (x: x != null) list;
|
keyedHosts = filter (x: x != null) list;
|
||||||
in listToAttrs keyedHosts;
|
in listToAttrs keyedHosts;
|
||||||
|
|
||||||
services.collectd = lib.mkIf cfg.hq.statistics.enable {
|
|
||||||
enable = true;
|
|
||||||
extraConfig = ''
|
|
||||||
FQDNLookup false
|
|
||||||
Interval 10
|
|
||||||
'';
|
|
||||||
buildMinimalPackage = true;
|
|
||||||
plugins = {
|
|
||||||
logfile = ''
|
|
||||||
LogLevel info
|
|
||||||
File STDOUT
|
|
||||||
'';
|
|
||||||
network = ''
|
|
||||||
Server "grafana.serv.zentralwerk.dn42" "25826"
|
|
||||||
'';
|
|
||||||
memory = "";
|
|
||||||
processes = "";
|
|
||||||
disk = "";
|
|
||||||
df = "";
|
|
||||||
cpu = "";
|
|
||||||
entropy = "";
|
|
||||||
load = "";
|
|
||||||
swap = "";
|
|
||||||
cgroups = "";
|
|
||||||
vmem = "";
|
|
||||||
interface = "";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.mpd.extraConfig = lib.mkIf cfg.hq.enableMpdProxy ''
|
services.mpd.extraConfig = lib.mkIf cfg.hq.enableMpdProxy ''
|
||||||
database {
|
database {
|
||||||
plugin "proxy"
|
plugin "proxy"
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
{ lib, config, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
cfg = config.c3d2.hq.statistics;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.c3d2.hq.statistics = {
|
||||||
|
enable = lib.mkEnableOption "statistics collection";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = {
|
||||||
|
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.dn42" "25826"
|
||||||
|
'';
|
||||||
|
memory = "";
|
||||||
|
processes = "";
|
||||||
|
disk = "";
|
||||||
|
df = "";
|
||||||
|
cpu = "";
|
||||||
|
entropy = "";
|
||||||
|
load = "";
|
||||||
|
swap = "";
|
||||||
|
cgroups = "";
|
||||||
|
vmem = "";
|
||||||
|
interface = "";
|
||||||
|
} // lib.optionalAttrs config.services.nginx.enable {
|
||||||
|
nginx = ''
|
||||||
|
URL "http://localhost/nginx_status"
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx = lib.mkIf config.services.nginx.enable {
|
||||||
|
virtualHosts.localhost.locations."/nginx_status".extraConfig = ''
|
||||||
|
stub_status;
|
||||||
|
|
||||||
|
access_log off;
|
||||||
|
allow 127.0.0.1;
|
||||||
|
allow ::1;
|
||||||
|
deny all;
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue