Jef Practice: Update Sensu Go systemd managed services executable path to include Ruby plugins

By default the sensu-go services (sensu-backend and sensu-agent) don’t come configured to include the ruby plugins path provided by the sensu-plugins-ruby package.

If you want to use ruby plugins installed using sensu-install utility you have to specify the full path in the check command. That can get cumbersome, and on top of that, if you are using some agents with plugins installed into a different ruby environment, the check won’t work.

But with a small override adjustment to the systemd config, you can set the executable paths to search to include the ruby plugins. Here’s how:

Each of the Sensu Go service definitions provided as part of package install come configured to read in environment variables from a file in either /etc/default or /etc/sysconfig.

For sensu-backend
create the file /etc/default/sensu-backend or /etc/sysconfig/sensu-backend with:

PATH=/opt/sensu-plugins-ruby/embedded/bin/:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

For sensu-agent
create the file /etc/default/sensu-agent or /etc/sysconfig/sensu-agent with:

PATH=/opt/sensu-plugins-ruby/embedded/bin/:/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

restart each of the services to have the new PATH take effect.

Now both backend and agent should have the updated path and you can write checks that use sensu-plugin commands without the full address.

Note: systemd knows to look in /etc/systemd/<service-name>.service.d/ directory for local administrator overrides for each installed service. Generally you want to avoid editting the service files provided as part of packaging, and use override files for local configuration adjustments.