mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2025-01-05 20:11:43 +03:00
collectd service: minor refactoring
* removed pid-file support, it is needless to run collectd as systemd service * removed static user id, as all the files reowned on the service start * added ambient capabilities for ping and smart (hdd health) functions
This commit is contained in:
parent
dc9f69c260
commit
67340baa9b
@ -166,7 +166,7 @@
|
|||||||
dnsmasq = 141;
|
dnsmasq = 141;
|
||||||
uhub = 142;
|
uhub = 142;
|
||||||
yandexdisk = 143;
|
yandexdisk = 143;
|
||||||
collectd = 144;
|
#collectd = 144; #unused
|
||||||
consul = 145;
|
consul = 145;
|
||||||
mailpile = 146;
|
mailpile = 146;
|
||||||
redmine = 147;
|
redmine = 147;
|
||||||
|
@ -7,7 +7,6 @@ let
|
|||||||
|
|
||||||
conf = pkgs.writeText "collectd.conf" ''
|
conf = pkgs.writeText "collectd.conf" ''
|
||||||
BaseDir "${cfg.dataDir}"
|
BaseDir "${cfg.dataDir}"
|
||||||
PIDFile "${cfg.pidFile}"
|
|
||||||
AutoLoadPlugin ${boolToString cfg.autoLoadPlugin}
|
AutoLoadPlugin ${boolToString cfg.autoLoadPlugin}
|
||||||
Hostname "${config.networking.hostName}"
|
Hostname "${config.networking.hostName}"
|
||||||
|
|
||||||
@ -26,13 +25,7 @@ let
|
|||||||
|
|
||||||
in {
|
in {
|
||||||
options.services.collectd = with types; {
|
options.services.collectd = with types; {
|
||||||
enable = mkOption {
|
enable = mkEnableOption "collectd agent";
|
||||||
default = false;
|
|
||||||
description = ''
|
|
||||||
Whether to enable collectd agent.
|
|
||||||
'';
|
|
||||||
type = bool;
|
|
||||||
};
|
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
default = pkgs.collectd;
|
default = pkgs.collectd;
|
||||||
@ -59,14 +52,6 @@ in {
|
|||||||
type = path;
|
type = path;
|
||||||
};
|
};
|
||||||
|
|
||||||
pidFile = mkOption {
|
|
||||||
default = "/var/run/collectd.pid";
|
|
||||||
description = ''
|
|
||||||
Location of collectd pid file.
|
|
||||||
'';
|
|
||||||
type = path;
|
|
||||||
};
|
|
||||||
|
|
||||||
autoLoadPlugin = mkOption {
|
autoLoadPlugin = mkOption {
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
@ -100,27 +85,21 @@ in {
|
|||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
ExecStart = "${cfg.package}/sbin/collectd -C ${conf} -P ${cfg.pidFile}";
|
ExecStart = "${cfg.package}/sbin/collectd -C ${conf} -f";
|
||||||
Type = "forking";
|
User = cfg.user;
|
||||||
PIDFile = cfg.pidFile;
|
AmbientCapabilities = "cap_net_raw cap_dac_override"; # cap_net_raw for ping, cap_dac_override for smart
|
||||||
User = optional (cfg.user!="root") cfg.user;
|
|
||||||
PermissionsStartOnly = true;
|
PermissionsStartOnly = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
preStart = ''
|
preStart = ''
|
||||||
mkdir -p ${cfg.dataDir}
|
mkdir -p "${cfg.dataDir}"
|
||||||
chmod 755 ${cfg.dataDir}
|
chmod 755 "${cfg.dataDir}"
|
||||||
install -D /dev/null ${cfg.pidFile}
|
chown -R ${cfg.user} "${cfg.dataDir}"
|
||||||
if [ "$(id -u)" = 0 ]; then
|
|
||||||
chown -R ${cfg.user} ${cfg.dataDir};
|
|
||||||
chown ${cfg.user} ${cfg.pidFile}
|
|
||||||
fi
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
users.extraUsers = optional (cfg.user == "collectd") {
|
users.extraUsers = optional (cfg.user == "collectd") {
|
||||||
name = "collectd";
|
name = "collectd";
|
||||||
uid = config.ids.uids.collectd;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user