Telegraf does not find pgrep, is it packaged wrongly?

I’m using telegraf and have several modules configured without issues.
I do have issue with configuration of inputs.procstat.

  1. I had to first specifically request procps to be installed
  2. Then I’m getting error ‘> [inputs.procstat] Error in plugin: could not find pgrep binary: exec: “pgrep”: executable file not found in $PATH’

pgrep is installed (explicitely by procps) but is not listed in the PATH in /nix/store/HASH-system-units/telegraf.service, [Service], Environment.

I’m using

  • nixos-version: 23.05.3580.5d017a8822e0 (Stoat)
  • telegraf-1.26.2, I believe

Do I understand it right that

  1. it should not be required for me to request installation of procps but that that should be done automatically once you request inputs.procstat module?
  2. pgrep should be included in the PATH as well?

Anyway, how can I add pgrep’s path to PATH?

Bard is suggesting the following which does not work:

services.telegraf.serviceConfig.Environment = {
PATH = “${systemd.services.telegraf.serviceConfig.Environment.PATH}//:/run/current-system/sw/bin”;
};

and neither does

services.telegraf.serviceConfig.Environment = {
PATH = “${services.telegraf.serviceConfig.Environment.PATH}//:/run/current-system/sw/bin”;
};

1 Like

The systemd unit interface allows passing executables in a package into the PATH via path.

{ pkgs }:
{
  systemd.services.telegraf.path = with pkgs; [
    procps
  ];
}
1 Like

Thanks! This works now!

Is such behavior intended?

1 Like

No, this is just a local workaround, that shows that this is missing from the runtime environment defined in the systemd unit.

This change should probably be submitted for inclusion into nixpkgs.

1 Like

OK, thx! Just checking if I understand the concept correctly.

1 Like
2 Likes