nixos/telegraf: include procps if procstat input is configured

This commit is contained in:
Jörg Thalheim 2023-09-23 18:17:41 +02:00 committed by Jörg Thalheim
parent 8ae9c8640c
commit 501680a656
2 changed files with 6 additions and 0 deletions

View file

@ -53,6 +53,10 @@ in {
###### implementation
config = mkIf config.services.telegraf.enable {
services.telegraf.extraConfig = {
inputs = {};
outputs = {};
};
systemd.services.telegraf = let
finalConfigFile = if config.services.telegraf.environmentFiles == []
then configFile
@ -61,6 +65,7 @@ in {
description = "Telegraf Agent";
wantedBy = [ "multi-user.target" ];
after = [ "network-online.target" ];
path = lib.optional (config.services.telegraf.extraConfig.inputs ? procstat) pkgs.procps;
serviceConfig = {
EnvironmentFile = config.services.telegraf.environmentFiles;
ExecStartPre = lib.optional (config.services.telegraf.environmentFiles != [])

View file

@ -12,6 +12,7 @@ import ./make-test-python.nix ({ pkgs, ...} : {
services.telegraf.extraConfig = {
agent.interval = "1s";
agent.flush_interval = "1s";
inputs.procstat = {};
inputs.exec = {
commands = [
"${pkgs.runtimeShell} -c 'echo $SECRET,tag=a i=42i'"