diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-10 13:28:20 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-10 13:28:20 +0200 |
commit | 5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010 (patch) | |
tree | a6c0f605be6de3f372ae69905b331f9f75452da7 /nixos/modules/services/monitoring/statsd.nix | |
parent | 6070bc016bd2fd945b04347e25cfd3738622d2ac (diff) | |
download | nixlib-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar nixlib-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.gz nixlib-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.bz2 nixlib-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.lz nixlib-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.xz nixlib-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.tar.zst nixlib-5c1f8cbc70cd5e6867ef6a2a06d27a40daa07010.zip |
Move all of NixOS to nixos/ in preparation of the repository merge
Diffstat (limited to 'nixos/modules/services/monitoring/statsd.nix')
-rw-r--r-- | nixos/modules/services/monitoring/statsd.nix | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/statsd.nix b/nixos/modules/services/monitoring/statsd.nix new file mode 100644 index 000000000000..a32666056714 --- /dev/null +++ b/nixos/modules/services/monitoring/statsd.nix @@ -0,0 +1,94 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +let + + cfg = config.services.statsd; + + configFile = pkgs.writeText "statsd.conf" '' + { + host: "${cfg.host}", + port: "${toString cfg.port}", + backends: [${concatMapStrings (el: ''"./backends/${el}",'') cfg.backends}], + graphiteHost: "${cfg.graphiteHost}", + graphitePort: "${toString cfg.graphitePort}", + ${cfg.extraConfig} + } + ''; + +in + +{ + + ###### interface + + options.services.statsd = { + + enable = mkOption { + description = "Whether to enable statsd stats aggregation service"; + default = false; + type = types.uniq types.bool; + }; + + host = mkOption { + description = "Address that statsd listens on over UDP"; + default = "127.0.0.1"; + type = types.uniq types.string; + }; + + port = mkOption { + description = "Port that stats listens for messages on over UDP"; + default = 8125; + type = types.uniq types.int; + }; + + backends = mkOption { + description = "List of backends statsd will use for data persistance"; + default = ["graphite"]; + }; + + graphiteHost = mkOption { + description = "Hostname or IP of Graphite server"; + default = "127.0.0.1"; + type = types.uniq types.string; + }; + + graphitePort = mkOption { + description = "Port of Graphite server"; + default = 2003; + type = types.uniq types.int; + }; + + extraConfig = mkOption { + default = ""; + description = "Extra configuration options for statsd"; + type = types.uniq types.string; + }; + + }; + + ###### implementation + + config = mkIf cfg.enable { + + users.extraUsers = singleton { + name = "statsd"; + uid = config.ids.uids.statsd; + description = "Statsd daemon user"; + }; + + systemd.services.statsd = { + description = "Statsd Server"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${pkgs.nodePackages.statsd}/bin/statsd ${configFile}"; + User = "statsd"; + }; + }; + + environment.systemPackages = [pkgs.nodePackages.statsd]; + + }; + +} |