diff --git a/templates/nrpe-check_generic.cfg.erb b/templates/nrpe-check_generic.cfg.erb index a4a0dfb8..4040ff88 100644 --- a/templates/nrpe-check_generic.cfg.erb +++ b/templates/nrpe-check_generic.cfg.erb @@ -1,2 +1,7 @@ # Configuration for <%= @title %> (from the generic template) -command[<%= @command %>]=<% if @sudo %>sudo <% if @sudo_user %>-u <%= @sudo_user %> <% end %><% end %><%= scope.lookupvar('nagios::client::plugin_dir') %>/<%= @plugin %><% if @args.to_s != '' %> <%= @args %><% end %> +<%- +require 'pathname' +plugincmd = Pathname.new(@plugin).absolute? ? @plugin : "#{scope.lookupvar('nagios::client::plugin_dir')}/#{@plugin}" +sudooption = @sudo ? ('sudo ' + (@sudo_user ? "-u #{@sudo_user} " : '')) : '' +-%> +command[<%= @command %>]=<%= sudooption %><%= plugincmd %><% if @args %> <%= @args %><% end %> diff --git a/templates/plugins/check_postgres-sudoers.erb b/templates/plugins/check_postgres-sudoers.erb index 38e32f3d..1ec7d33d 100644 --- a/templates/plugins/check_postgres-sudoers.erb +++ b/templates/plugins/check_postgres-sudoers.erb @@ -1,2 +1,6 @@ Defaults !requiretty -<%= scope['nagios::client::nrpe_user'] %> ALL = (<%= @privileged_user %>) NOPASSWD: <%= scope['nagios::client::plugin_dir'] %>/<%= @plugin %> +<%- +require 'pathname' +plugincmd = Pathname.new(@plugin).absolute? ? @plugin : "#{scope['nagios::client::plugin_dir']}/#{@plugin}" +-%> +<%= scope['nagios::client::nrpe_user'] %> ALL = (<%= @privileged_user %>) NOPASSWD: <%= plugincmd %>