1 { config, lib, pkgs, ... }:
6 cfg = config.services.scollector;
8 collectors = pkgs.runCommand "collectors" { preferLocalBuild = true; }
11 ${lib.concatStringsSep
15 "mkdir -p $out/${frequency}\n" +
18 (map (path: "ln -s ${path} $out/${frequency}/$(basename ${path})")
23 conf = pkgs.writeText "scollector.toml" ''
24 Host = "${cfg.bosunHost}"
25 ColDir = "${collectors}"
33 services.scollector = {
39 Whether to run scollector.
43 package = mkPackageOption pkgs "scollector" { };
47 default = "scollector";
49 User account under which scollector runs.
55 default = "scollector";
57 Group account under which scollector runs.
61 bosunHost = mkOption {
63 default = "localhost:8070";
65 Host and port of the bosun server that will store the collected
70 collectors = mkOption {
71 type = with types; attrsOf (listOf path);
73 example = literalExpression ''{ "0" = [ "''${postgresStats}/bin/collect-stats" ]; }'';
75 An attribute set mapping the frequency of collection to a list of
76 binaries that should be executed at that frequency. You can use "0"
77 to run a binary forever.
81 extraOpts = mkOption {
82 type = with types; listOf str;
86 Extra scollector command line options
90 extraConfig = mkOption {
94 Extra scollector configuration added to the end of scollector.toml
102 config = mkIf config.services.scollector.enable {
104 systemd.services.scollector = {
105 description = "scollector metrics collector (part of Bosun)";
106 wantedBy = [ "multi-user.target" ];
108 path = [ pkgs.coreutils pkgs.iproute2 ];
113 ExecStart = "${cfg.package}/bin/scollector -conf=${conf} ${lib.concatStringsSep " " cfg.extraOpts}";
117 users.users.scollector = {
118 description = "scollector user";
119 group = "scollector";
120 uid = config.ids.uids.scollector;
123 users.groups.scollector.gid = config.ids.gids.scollector;