Skip to content

Commit

Permalink
Create netdata node uuid with hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
rhoriguchi committed Dec 18, 2024
1 parent 800e83b commit c9a6bd8
Showing 1 changed file with 40 additions and 10 deletions.
50 changes: 40 additions & 10 deletions modules/default/monitoring.nix
Original file line number Diff line number Diff line change
Expand Up @@ -290,16 +290,46 @@ in {
};
};

systemd.services.netdata.serviceConfig = {
CapabilityBoundingSet = [
# S.M.A.R.T. collector
"CAP_SYS_RAWIO"
];

AmbientCapabilities = [
# Ping collector
"CAP_NET_RAW"
];
systemd.services = {
netdata = {
requires = [ "netdata-set-node-uuid.service" ];

serviceConfig = {
CapabilityBoundingSet = [
# S.M.A.R.T. collector
"CAP_SYS_RAWIO"
];

AmbientCapabilities = [
# Ping collector
"CAP_NET_RAW"
];
};
};

netdata-set-node-uuid = {
before = [ "netdata.service" ];
wantedBy = [ "multi-user.target" ];

serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
User = config.services.netdata.user;
Group = config.services.netdata.group;
};

script = ''
${pkgs.coreutils}/bin/mkdir -p /var/lib/netdata/registry
hash=$(echo -n "${config.networking.hostName}" | ${pkgs.coreutils}/bin/sha1sum | ${pkgs.gawk}/bin/awk '{print $1}')
printf "%s-%s-%s-%s-%s" \
"''${hash:0:8}" \
"''${hash:8:4}" \
"''${hash:12:4}" \
"''${hash:16:4}" \
"''${hash:20:12}" > /var/lib/netdata/registry/netdata.public.unique.id
'';
};
};

users.users.${config.services.netdata.user}.extraGroups =
Expand Down

0 comments on commit c9a6bd8

Please sign in to comment.