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 = {
38 description = lib.mdDoc ''
39 Whether to run scollector.
45 default = pkgs.scollector;
46 defaultText = literalExpression "pkgs.scollector";
47 description = lib.mdDoc ''
48 scollector binary to use.
54 default = "scollector";
55 description = lib.mdDoc ''
56 User account under which scollector runs.
62 default = "scollector";
63 description = lib.mdDoc ''
64 Group account under which scollector runs.
68 bosunHost = mkOption {
70 default = "localhost:8070";
71 description = lib.mdDoc ''
72 Host and port of the bosun server that will store the collected
77 collectors = mkOption {
78 type = with types; attrsOf (listOf path);
80 example = literalExpression ''{ "0" = [ "''${postgresStats}/bin/collect-stats" ]; }'';
81 description = lib.mdDoc ''
82 An attribute set mapping the frequency of collection to a list of
83 binaries that should be executed at that frequency. You can use "0"
84 to run a binary forever.
88 extraOpts = mkOption {
89 type = with types; listOf str;
92 description = lib.mdDoc ''
93 Extra scollector command line options
97 extraConfig = mkOption {
100 description = lib.mdDoc ''
101 Extra scollector configuration added to the end of scollector.toml
109 config = mkIf config.services.scollector.enable {
111 systemd.services.scollector = {
112 description = "scollector metrics collector (part of Bosun)";
113 wantedBy = [ "multi-user.target" ];
115 path = [ pkgs.coreutils pkgs.iproute2 ];
120 ExecStart = "${cfg.package}/bin/scollector -conf=${conf} ${lib.concatStringsSep " " cfg.extraOpts}";
124 users.users.scollector = {
125 description = "scollector user";
126 group = "scollector";
127 uid = config.ids.uids.scollector;
130 users.groups.scollector.gid = config.ids.gids.scollector;