summaryrefslogtreecommitdiffstats
path: root/lass
diff options
context:
space:
mode:
authorlassulus <lass@lassul.us>2017-01-09 17:07:59 +0100
committerlassulus <lass@lassul.us>2017-01-09 17:07:59 +0100
commit43eaeee506939af8dc1d169754c5279b2372a134 (patch)
treee9d95dfa24103b5eb4487bd14e1dfa8122d5b544 /lass
parent91c4f86b31941843ab4a9788dc76ebf18adc871f (diff)
l 3: add telegraf service
Diffstat (limited to 'lass')
-rw-r--r--lass/3modules/default.nix1
-rw-r--r--lass/3modules/telegraf.nix67
2 files changed, 68 insertions, 0 deletions
diff --git a/lass/3modules/default.nix b/lass/3modules/default.nix
index b169fea40..1046fb7cd 100644
--- a/lass/3modules/default.nix
+++ b/lass/3modules/default.nix
@@ -9,5 +9,6 @@ _:
./urxvtd.nix
./usershadow.nix
./xresources.nix
+ ./telegraf.nix
];
}
diff --git a/lass/3modules/telegraf.nix b/lass/3modules/telegraf.nix
new file mode 100644
index 000000000..64b323460
--- /dev/null
+++ b/lass/3modules/telegraf.nix
@@ -0,0 +1,67 @@
+{ 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";
+ };
+ config = mkOption {
+ type = types.str;
+ #TODO: find a good default
+ default = ''
+ [agent]
+ interval = "1s"
+
+ [outputs]
+
+ # Configuration to send data to InfluxDB.
+ [outputs.influxdb]
+ urls = ["http://localhost:8086"]
+ database = "kapacitor_example"
+ user_agent = "telegraf"
+
+ # Collect metrics about cpu usage
+ [cpu]
+ percpu = false
+ totalcpu = true
+ drop = ["cpu_time"]
+ '';
+ 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