about summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/scollector.nix
diff options
context:
space:
mode:
authorOliver Charles <ollie@ocharles.org.uk>2014-11-20 14:38:04 +0000
committerOliver Charles <ollie@ocharles.org.uk>2014-11-24 14:40:47 +0000
commit2ed07c6cc1ce6c2e1c91f87630633dd92057e72b (patch)
tree9180036ee1c1673ced24fda19fedacd13c0e5063 /nixos/modules/services/monitoring/scollector.nix
parent751a2943f49bdbc9a231ccf2d748c171ed3d6389 (diff)
scollector: New NixOS module
Diffstat (limited to 'nixos/modules/services/monitoring/scollector.nix')
-rw-r--r--nixos/modules/services/monitoring/scollector.nix88
1 files changed, 88 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/scollector.nix b/nixos/modules/services/monitoring/scollector.nix
new file mode 100644
index 0000000000000..3d52631538b09
--- /dev/null
+++ b/nixos/modules/services/monitoring/scollector.nix
@@ -0,0 +1,88 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.scollector;
+
+in {
+
+  options = {
+
+    services.scollector = {
+
+      enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Whether to run scollector.
+        '';
+      };
+
+      package = mkOption {
+        type = types.package;
+        default = pkgs.scollector;
+        example = literalExample "pkgs.scollector";
+        description = ''
+          scollector binary to use.
+        '';
+      };
+
+      user = mkOption {
+        type = types.string;
+        default = "scollector";
+        description = ''
+          User account under which scollector runs.
+        '';
+      };
+
+      group = mkOption {
+        type = types.string;
+        default = "scollector";
+        description = ''
+          Group account under which scollector runs.
+        '';
+      };
+
+      opentsdbHost = mkOption {
+        type = types.string;
+        default = "localhost:4242";
+        description = ''
+          Host and port of the OpenTSDB database that will store the collected
+          data.
+        '';
+      };
+
+    };
+
+  };
+
+  config = mkIf config.services.scollector.enable {
+
+    systemd.services.scollector = {
+      description = "scollector metrics collector (part of Bosun)";
+      wantedBy = [ "multi-user.target" ];
+
+      path = [ pkgs.coreutils pkgs.iproute ];
+
+      serviceConfig = {
+        PermissionsStartOnly = true;
+        User = cfg.user;
+        Group = cfg.group;
+        ExecStart = ''
+          ${cfg.package}/bin/scollector -h=${cfg.opentsdbHost}
+        '';
+      };
+    };
+
+    users.extraUsers.scollector = {
+      description = "scollector user";
+      group = "scollector";
+      uid = config.ids.uids.scollector;
+    };
+
+    users.extraGroups.scollector.gid = config.ids.gids.scollector;
+
+  };
+
+}