From 25597af7630ba57a771c90748dd7e0d18e42052b Mon Sep 17 00:00:00 2001 From: lassulus Date: Sun, 5 Feb 2017 00:48:06 +0100 Subject: l 3: remove urxvtd --- lass/3modules/default.nix | 1 - lass/3modules/urxvtd.nix | 55 ----------------------------------------------- 2 files changed, 56 deletions(-) delete mode 100644 lass/3modules/urxvtd.nix (limited to 'lass/3modules') diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index 2bf2df8b3..f97b041ac 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -6,7 +6,6 @@ _: ./hosts.nix ./mysql-backup.nix ./umts.nix - ./urxvtd.nix ./usershadow.nix ./xresources.nix ./kapacitor.nix diff --git a/lass/3modules/urxvtd.nix b/lass/3modules/urxvtd.nix deleted file mode 100644 index 469616a9f..000000000 --- a/lass/3modules/urxvtd.nix +++ /dev/null @@ -1,55 +0,0 @@ -{ config, lib, pkgs, ... }: - -let -in - -with builtins; -with lib; - -{ - options = { - services.urxvtd = { - enable = mkOption { - type = types.bool; - default = false; - description = "Enable urxvtd per user"; - }; - users = mkOption { - type = types.listOf types.string; - default = []; - description = "users to run urxvtd for"; - }; - urxvtPackage = mkOption { - type = types.package; - default = pkgs.rxvt_unicode; - description = "urxvt package to use"; - }; - }; - }; - - config = - let - cfg = config.services.urxvtd; - users = cfg.users; - urxvt = cfg.urxvtPackage; - mkService = user: { - description = "urxvt terminal daemon"; - wantedBy = [ "multi-user.target" ]; - restartIfChanged = false; - path = [ pkgs.xlibs.xrdb ]; - environment = { - DISPLAY = ":0"; - URXVT_PERL_LIB = "${urxvt}/lib/urxvt/perl"; - }; - serviceConfig = { - Restart = "always"; - User = user; - ExecStart = "${urxvt}/bin/urxvtd"; - }; - }; - in - mkIf cfg.enable { - environment.systemPackages = [ urxvt ]; - systemd.services = listToAttrs (map (u: { name = "${u}-urxvtd"; value = mkService u; }) users); - }; -} -- cgit v1.2.3 From 73f72eeaf128104328b5e53257e3ca92c8441df5 Mon Sep 17 00:00:00 2001 From: lassulus Date: Mon, 6 Feb 2017 19:13:59 +0100 Subject: l 3: remove obsolete telegraf module --- lass/3modules/default.nix | 1 - lass/3modules/telegraf.nix | 84 ---------------------------------------------- 2 files changed, 85 deletions(-) delete mode 100644 lass/3modules/telegraf.nix (limited to 'lass/3modules') diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index f97b041ac..f4a2b4565 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -9,6 +9,5 @@ _: ./usershadow.nix ./xresources.nix ./kapacitor.nix - ./telegraf.nix ]; } diff --git a/lass/3modules/telegraf.nix b/lass/3modules/telegraf.nix deleted file mode 100644 index 0b3be2d69..000000000 --- a/lass/3modules/telegraf.nix +++ /dev/null @@ -1,84 +0,0 @@ -{ config, lib, pkgs, ... }: - -with builtins; -with lib; - -let - cfg = config.lass.telegraf; - - out = { - options.lass.telegraf = api; - config = mkIf cfg.enable imp; - }; - - api = { - enable = mkEnableOption "telegraf"; - dataDir = mkOption { - type = types.str; - default = "/var/lib/telegraf"; - }; - user = mkOption { - type = types.str; - default = "telegraf"; - }; - outputs = mkOption { - type = types.str; - default = '' - [outputs.influxdb] - urls = ["http://localhost:8086"] - database = "telegraf_db" - user_agent = "telegraf" - ''; - }; - inputs = mkOption { - type = with types; listOf str; - default = [ - '' - [cpu] - percpu = false - totalcpu = true - drop = ["cpu_time"] - '' - ]; - }; - interval = mkOption { - type = types.str; - default = "10s"; - }; - config = mkOption { - type = types.str; - #TODO: find a good default - default = '' - [agent] - interval = "${cfg.interval}" - - [outputs] - - ${cfg.outputs} - - ${concatStringsSep "\n" cfg.inputs} - - ''; - description = "configuration telegraf is started with"; - }; - }; - - configFile = pkgs.writeText "telegraf.conf" cfg.config; - - imp = { - - systemd.services.telegraf = { - description = "telegraf"; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - - restartIfChanged = true; - - serviceConfig = { - Restart = "always"; - ExecStart = "${pkgs.telegraf}/bin/telegraf -config ${configFile}"; - }; - }; - }; - -in out -- cgit v1.2.3 From 2b68541e297fd6fcb67a117c7d816dbcca9e8c64 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 7 Feb 2017 17:09:39 +0100 Subject: l 3 kapacitor: use extraConfig & start as user --- lass/3modules/kapacitor.nix | 188 +++++++++++++++++++++++++------------------- 1 file changed, 109 insertions(+), 79 deletions(-) (limited to 'lass/3modules') diff --git a/lass/3modules/kapacitor.nix b/lass/3modules/kapacitor.nix index 299a56d92..092890814 100644 --- a/lass/3modules/kapacitor.nix +++ b/lass/3modules/kapacitor.nix @@ -1,7 +1,7 @@ { config, lib, pkgs, ... }: with builtins; -with lib; +with import ; let cfg = config.lass.kapacitor; @@ -11,6 +11,71 @@ let config = mkIf cfg.enable imp; }; + configOptions = recursiveUpdate { + hostname = "localhost"; + data_dir = cfg.dataDir; + http = { + bind-address = ":9092"; + auth-enabled = false; + log-enabled = false; + gtgwrite-tracing = false; + pprof-enabled = false; + https-enabled = false; + https-certificate = "/etc/ssl/kapacitor.pem"; + shutdown-timeout = "10s"; + shared-secret = ""; + }; + + replay ={ + dir = "${cfg.dataDir}/replay"; + }; + + storage = { + boltdb = "${cfg.dataDir}/kapacitor.db"; + }; + + task = { + dir = "${cfg.dataDir}/tasks"; + snapshot-interval = "1m0s"; + }; + + influxdb = [{ + enabled = true; + name = "default"; + default = false; + urls = ["http://localhost:8086"]; + username = ""; + password = ""; + ssl-ca = ""; + ssl-cert = ""; + ssl-key = ""; + insecure-skip-verify = false; + timeout = "0s"; + disable-subscriptions = false; + subscription-protocol = "http"; + udp-bind = ""; + udp-buffer = 1000; + udp-read-buffer = 0; + startup-timeout = "5m0s"; + subscriptions-sync-interval = "1m0s"; + influxdb.excluded-subscriptions = { + _kapacitor = ["autogen"]; + }; + }]; + + logging = { + file = "STDERR"; + level = "INFO"; + }; + + deadman = { + interval = "10s"; + id = "{{ .Group }}:NODE_NAME for task '{{ .TaskName }}'"; + message = "{{ .ID }} is {{ if eq .Level \"OK\" }}alive{{ else }}dead{{ end }}: {{ index .Fields \"emitted\" | printf \"%0.3f\" }} points/INTERVAL."; + global = false; + }; + } cfg.extraConfig; + api = { enable = mkEnableOption "kapacitor"; dataDir = mkOption { @@ -18,90 +83,54 @@ let default = "/var/lib/kapacitor"; }; user = mkOption { - type = types.str; - default = "kapacitor"; + type = types.user; + default = { + name = "kapacitor"; + home = cfg.dataDir; + }; }; - logLevel = mkOption { - type = types.enum ["DEBUG" "INFO" "WARN" "ERROR" "OFF"]; - default = "INFO"; + group = mkOption { + type = types.group; + default = { + name = "kapacitor"; + }; }; - alarms = mkOption { - type = with types; attrsOf str; + extraConfig = mkOption { + type = types.attrs; default = {}; }; - check_db = mkOption { - type = types.str; - default = "all_data"; - }; - config = mkOption { - type = types.str; - #TODO: find a good default - default = '' - hostname = "localhost" - data_dir = "${cfg.dataDir}" - - [http] - bind-address = ":9092" - auth-enabled = false - log-enabled = true - write-tracing = false - pprof-enabled = false - https-enabled = false - https-certificate = "/etc/ssl/kapacitor.pem" - shutdown-timeout = "10s" - shared-secret = "" - - [replay] - dir = "${cfg.dataDir}/replay" - - [storage] - boltdb = "${cfg.dataDir}/kapacitor.db" - - [task] - dir = "${cfg.dataDir}/tasks" - snapshot-interval = "1m0s" - - [[influxdb]] - enabled = true - name = "default" - default = false - urls = ["http://localhost:8086"] - username = "" - password = "" - ssl-ca = "" - ssl-cert = "" - ssl-key = "" - insecure-skip-verify = false - timeout = "0s" - disable-subscriptions = false - subscription-protocol = "http" - udp-bind = "" - udp-buffer = 1000 - udp-read-buffer = 0 - startup-timeout = "5m0s" - subscriptions-sync-interval = "1m0s" - [influxdb.subscriptions] - [influxdb.excluded-subscriptions] - _kapacitor = ["autogen"] - - [logging] - file = "STDERR" - level = "${cfg.logLevel}" - - [deadman] - interval = "10s" - threshold = 0.0 - id = "{{ .Group }}:NODE_NAME for task '{{ .TaskName }}'" - message = "{{ .ID }} is {{ if eq .Level \"OK\" }}alive{{ else }}dead{{ end }}: {{ index .Fields \"emitted\" | printf \"%0.3f\" }} points/INTERVAL." - global = false - ''; - description = "configuration kapacitor is started with"; + alarms = mkOption { + type = with types; attrsOf (submodule { + options = { + database = mkOption { + type = str; + }; + text = mkOption { + type = str; + }; + }; + }); + default = {}; }; }; - configFile = pkgs.writeText "kapacitor.conf" cfg.config; + configFile = pkgs.runCommand "kapacitor.toml" {} '' + ${pkgs.remarshal}/bin/remarshal -if json -of toml \ + < ${pkgs.writeText "kapacitor.json" (builtins.toJSON configOptions)} \ + > $out + ''; imp = { + users = { + groups.${cfg.group.name} = { + inherit (cfg.group) name gid; + }; + users.${cfg.user.name} = { + inherit (cfg.user) home name uid; + createHome = true; + group = cfg.group.name; + }; + }; systemd.services.kapacitor = { description = "kapacitor"; @@ -112,6 +141,7 @@ let serviceConfig = { Restart = "always"; + User = cfg.user.name; ExecStart = "${pkgs.kapacitor}/bin/kapacitord -config ${configFile}"; }; }; @@ -125,13 +155,14 @@ let serviceConfig = { Type = "oneshot"; + User = cfg.user.name; ExecStart = pkgs.writeDash "add_alarms" '' ${pkgs.kapacitor}/bin/kapacitor delete tasks \* ${concatStrings (mapAttrsToList (name: alarm: '' ${pkgs.kapacitor}/bin/kapacitor define ${name} \ -type batch \ - -tick ${pkgs.writeText "${name}.tick" alarm} \ - -dbrp ${cfg.check_db}.default + -tick ${pkgs.writeText "${name}.tick" alarm.text} \ + -dbrp ${alarm.database}.default ${pkgs.kapacitor}/bin/kapacitor enable ${name} '') cfg.alarms)} ''; @@ -139,5 +170,4 @@ let }; }; - in out -- cgit v1.2.3 From 54e16f7a9e059991c85098e5e274bbadb8e93497 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 7 Feb 2017 17:21:25 +0100 Subject: move kapacitor to k 3 --- lass/3modules/default.nix | 1 - lass/3modules/kapacitor.nix | 173 -------------------------------------------- 2 files changed, 174 deletions(-) delete mode 100644 lass/3modules/kapacitor.nix (limited to 'lass/3modules') diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix index f4a2b4565..959c9d1b4 100644 --- a/lass/3modules/default.nix +++ b/lass/3modules/default.nix @@ -8,6 +8,5 @@ _: ./umts.nix ./usershadow.nix ./xresources.nix - ./kapacitor.nix ]; } diff --git a/lass/3modules/kapacitor.nix b/lass/3modules/kapacitor.nix deleted file mode 100644 index 092890814..000000000 --- a/lass/3modules/kapacitor.nix +++ /dev/null @@ -1,173 +0,0 @@ -{ config, lib, pkgs, ... }: - -with builtins; -with import ; - -let - cfg = config.lass.kapacitor; - - out = { - options.lass.kapacitor = api; - config = mkIf cfg.enable imp; - }; - - configOptions = recursiveUpdate { - hostname = "localhost"; - data_dir = cfg.dataDir; - http = { - bind-address = ":9092"; - auth-enabled = false; - log-enabled = false; - gtgwrite-tracing = false; - pprof-enabled = false; - https-enabled = false; - https-certificate = "/etc/ssl/kapacitor.pem"; - shutdown-timeout = "10s"; - shared-secret = ""; - }; - - replay ={ - dir = "${cfg.dataDir}/replay"; - }; - - storage = { - boltdb = "${cfg.dataDir}/kapacitor.db"; - }; - - task = { - dir = "${cfg.dataDir}/tasks"; - snapshot-interval = "1m0s"; - }; - - influxdb = [{ - enabled = true; - name = "default"; - default = false; - urls = ["http://localhost:8086"]; - username = ""; - password = ""; - ssl-ca = ""; - ssl-cert = ""; - ssl-key = ""; - insecure-skip-verify = false; - timeout = "0s"; - disable-subscriptions = false; - subscription-protocol = "http"; - udp-bind = ""; - udp-buffer = 1000; - udp-read-buffer = 0; - startup-timeout = "5m0s"; - subscriptions-sync-interval = "1m0s"; - influxdb.excluded-subscriptions = { - _kapacitor = ["autogen"]; - }; - }]; - - logging = { - file = "STDERR"; - level = "INFO"; - }; - - deadman = { - interval = "10s"; - id = "{{ .Group }}:NODE_NAME for task '{{ .TaskName }}'"; - message = "{{ .ID }} is {{ if eq .Level \"OK\" }}alive{{ else }}dead{{ end }}: {{ index .Fields \"emitted\" | printf \"%0.3f\" }} points/INTERVAL."; - global = false; - }; - } cfg.extraConfig; - - api = { - enable = mkEnableOption "kapacitor"; - dataDir = mkOption { - type = types.str; - default = "/var/lib/kapacitor"; - }; - user = mkOption { - type = types.user; - default = { - name = "kapacitor"; - home = cfg.dataDir; - }; - }; - group = mkOption { - type = types.group; - default = { - name = "kapacitor"; - }; - }; - extraConfig = mkOption { - type = types.attrs; - default = {}; - }; - alarms = mkOption { - type = with types; attrsOf (submodule { - options = { - database = mkOption { - type = str; - }; - text = mkOption { - type = str; - }; - }; - }); - default = {}; - }; - }; - - configFile = pkgs.runCommand "kapacitor.toml" {} '' - ${pkgs.remarshal}/bin/remarshal -if json -of toml \ - < ${pkgs.writeText "kapacitor.json" (builtins.toJSON configOptions)} \ - > $out - ''; - - imp = { - users = { - groups.${cfg.group.name} = { - inherit (cfg.group) name gid; - }; - users.${cfg.user.name} = { - inherit (cfg.user) home name uid; - createHome = true; - group = cfg.group.name; - }; - }; - - systemd.services.kapacitor = { - description = "kapacitor"; - after = [ "network.target" ]; - wantedBy = [ "multi-user.target" ]; - - restartIfChanged = true; - - serviceConfig = { - Restart = "always"; - User = cfg.user.name; - ExecStart = "${pkgs.kapacitor}/bin/kapacitord -config ${configFile}"; - }; - }; - - systemd.services.kapacitor-alarms = { - description = "kapacitor-alarms"; - after = [ "kapacitor.service" ]; - wantedBy = [ "multi-user.target" ]; - - restartIfChanged = true; - - serviceConfig = { - Type = "oneshot"; - User = cfg.user.name; - ExecStart = pkgs.writeDash "add_alarms" '' - ${pkgs.kapacitor}/bin/kapacitor delete tasks \* - ${concatStrings (mapAttrsToList (name: alarm: '' - ${pkgs.kapacitor}/bin/kapacitor define ${name} \ - -type batch \ - -tick ${pkgs.writeText "${name}.tick" alarm.text} \ - -dbrp ${alarm.database}.default - ${pkgs.kapacitor}/bin/kapacitor enable ${name} - '') cfg.alarms)} - ''; - }; - }; - - }; -in out -- cgit v1.2.3