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-21 12:12:47 +0000
committerOliver Charles <ollie@ocharles.org.uk>2014-11-24 14:40:48 +0000
commitabd24523f3775e16845329ca6363c6e06162cabb (patch)
tree7e09f46a596a86e0c84aa5d7edb2b141c32087aa /nixos/modules/services/monitoring/scollector.nix
parent5a8d5f3094d2da8f8cc4e43bb28734a9d3e4f52d (diff)
downloadnixpkgs-abd24523f3775e16845329ca6363c6e06162cabb.tar
nixpkgs-abd24523f3775e16845329ca6363c6e06162cabb.tar.gz
nixpkgs-abd24523f3775e16845329ca6363c6e06162cabb.tar.bz2
nixpkgs-abd24523f3775e16845329ca6363c6e06162cabb.tar.lz
nixpkgs-abd24523f3775e16845329ca6363c6e06162cabb.tar.xz
nixpkgs-abd24523f3775e16845329ca6363c6e06162cabb.tar.zst
nixpkgs-abd24523f3775e16845329ca6363c6e06162cabb.zip
scollector: Allow users to specify external collectors
Diffstat (limited to 'nixos/modules/services/monitoring/scollector.nix')
-rw-r--r--nixos/modules/services/monitoring/scollector.nix28
1 files changed, 27 insertions, 1 deletions
diff --git a/nixos/modules/services/monitoring/scollector.nix b/nixos/modules/services/monitoring/scollector.nix
index ca0cbd97d89..ce70739abbc 100644
--- a/nixos/modules/services/monitoring/scollector.nix
+++ b/nixos/modules/services/monitoring/scollector.nix
@@ -5,6 +5,21 @@ with lib;
 let
   cfg = config.services.scollector;
 
+  collectors = pkgs.runCommand "collectors" {}
+    ''
+    mkdir -p $out
+    ${lib.concatStringsSep
+        "\n"
+        (lib.mapAttrsToList
+          (frequency: binaries:
+            "mkdir -p $out/${frequency}\n" +
+            (lib.concatStringsSep
+              "\n"
+              (map (path: "ln -s ${path} $out/${frequency}/$(basename ${path})")
+                   binaries)))
+          cfg.collectors)}
+    '';
+
 in {
 
   options = {
@@ -53,6 +68,17 @@ in {
         '';
       };
 
+      collectors = mkOption {
+        type = types.attrs;
+        default = {};
+        example = literalExample "{ 0 = [ \"\${postgresStats}/bin/collect-stats\" ]; }";
+        description = ''
+          An attribute set mapping the frequency of collection to a list of
+          binaries that should be executed at that frequency. You can use "0"
+          to run a binary forever.
+        '';
+      };
+
     };
 
   };
@@ -70,7 +96,7 @@ in {
         User = cfg.user;
         Group = cfg.group;
         ExecStart = ''
-          ${cfg.package}/bin/scollector -h=${cfg.bosunHost}
+          ${cfg.package}/bin/scollector -h=${cfg.bosunHost} -c=${collectors}
         '';
       };
     };