aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/monitoring/collectd.nix
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-01-10 20:09:37 +0000
committerKatharina Fey <kookie@spacekookie.de>2020-01-10 20:09:37 +0000
commit45431c078bf8f54aef7c9fae2e5913395ec82c31 (patch)
treefd8ff1346a963ddd72e782421f05b623f9759e2a /nixpkgs/nixos/modules/services/monitoring/collectd.nix
parentc86fea6086c212ea489cfb023a5f5c9c8f188810 (diff)
parent3ccbc8d89153ecf13f3eae7d9c106d91cd4ab9e5 (diff)
Merge commit '3ccbc8d89153ecf13f3eae7d9c106d91cd4ab9e5' into fuckthisshit
Diffstat (limited to 'nixpkgs/nixos/modules/services/monitoring/collectd.nix')
-rw-r--r--nixpkgs/nixos/modules/services/monitoring/collectd.nix40
1 files changed, 37 insertions, 3 deletions
diff --git a/nixpkgs/nixos/modules/services/monitoring/collectd.nix b/nixpkgs/nixos/modules/services/monitoring/collectd.nix
index 6a4c678eb21..731ac743b7c 100644
--- a/nixpkgs/nixos/modules/services/monitoring/collectd.nix
+++ b/nixpkgs/nixos/modules/services/monitoring/collectd.nix
@@ -16,13 +16,29 @@ let
NotifyLevel "OKAY"
</Plugin>
+ ${concatStrings (mapAttrsToList (plugin: pluginConfig: ''
+ LoadPlugin ${plugin}
+ <Plugin "${plugin}">
+ ${pluginConfig}
+ </Plugin>
+ '') cfg.plugins)}
+
${concatMapStrings (f: ''
- Include "${f}"
+ Include "${f}"
'') cfg.include}
${cfg.extraConfig}
'';
+ package =
+ if cfg.buildMinimalPackage
+ then minimalPackage
+ else cfg.package;
+
+ minimalPackage = cfg.package.override {
+ enabledPlugins = [ "syslog" ] ++ builtins.attrNames cfg.plugins;
+ };
+
in {
options.services.collectd = with types; {
enable = mkEnableOption "collectd agent";
@@ -33,7 +49,15 @@ in {
description = ''
Which collectd package to use.
'';
- type = package;
+ type = types.package;
+ };
+
+ buildMinimalPackage = mkOption {
+ default = false;
+ description = ''
+ Build a minimal collectd package with only the configured `services.collectd.plugins`
+ '';
+ type = types.bool;
};
user = mkOption {
@@ -68,6 +92,15 @@ in {
type = listOf str;
};
+ plugins = mkOption {
+ default = {};
+ example = { cpu = ""; memory = ""; network = "Server 192.168.1.1 25826"; };
+ description = ''
+ Attribute set of plugin names to plugin config segments
+ '';
+ type = types.attrsOf types.str;
+ };
+
extraConfig = mkOption {
default = "";
description = ''
@@ -89,7 +122,7 @@ in {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
- ExecStart = "${cfg.package}/sbin/collectd -C ${conf} -f";
+ ExecStart = "${package}/sbin/collectd -C ${conf} -f";
User = cfg.user;
Restart = "on-failure";
RestartSec = 3;
@@ -98,6 +131,7 @@ in {
users.users = optional (cfg.user == "collectd") {
name = "collectd";
+ isSystemUser = true;
};
};
}