0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

Merge pull request #71406 from astro/collectd

collectd: plugins configuration, buildMinimalPackage
This commit is contained in:
Franz Pletz 2019-10-21 10:34:34 +00:00 committed by GitHub
commit cc9b18f223
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 392 additions and 57 deletions

View file

@ -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;