You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the problem is not to get sudo working as expected, but to get the director and/or icinga2 to setup the paths correct and to expand the defined constant. At the moment I'm getting code like
Things would be easier if I could simply select a commandtype ' sudo Plugin Check Command' or select a checkbox 'Run as (sudo)' with perhaps a field for a sudo username in the 'new command' dialog.
In both cases director could use PluginDir as constant in the commands without side effects to generate the expected code:
Another option is to set 'sudo mode' in the service definition. So you don't have to define a command twice in case it should be executed with sudo on one system and without sudo on another....
In director it only adds "PluginDir" if you just use a relative path. If you use the full path it doesn't prefix it with PluginDir. An example is we have a plugin that uses icmp from Net::Ping which required root access. so for our "Command" we have /usr/bin/sudo /usr/lib/nagios/plugins/check_ap_status.pl and the "preview" tab shows
This issue has been migrated from Redmine: https://dev.icinga.com/issues/13213
Created by bcogel on 2016-11-16 13:11:42 +00:00
Assignee: (none)
Status: New
Target Version: (none)
Last Update: 2016-11-17 10:25:11 +00:00 (in Redmine)
I'm trying to set up a command to be used through sudo with director.
What does work:
object CheckCommand "eDIR Time" {
import "plugin-check-command"
command = [ "/usr/bin/sudo", "/usr/lib/nagios/plugins/check_edir_time" ]
}
OK: All reachable servers have time in sync. OK: All servers were contacted.
sudo: icinga : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/lib/nagios/plugins/check_edir_time
What doesn't work is to somehow replace "/usr/lib/nagios/plugins" with PluginDir. Depending on what I'm doing, I get the plugin result in Icinga:
sudo: Kein TTY vorhanden und kein »askpass«-Programm angegeben
and in the system log things like
sudo: icinga : command not allowed ; TTY=unknown ; PWD=/ ; USER=root ; COMMAND=check_edir_time
or
sudo: icinga : command not allowed ; TTY=unknown ; PWD=/ ; USER=root ; COMMAND=PluginDir+"/check_edir_time"
So the problem is not to get sudo working as expected, but to get the director and/or icinga2 to setup the paths correct and to expand the defined constant. At the moment I'm getting code like
command = [ PluginDir + "/sudo", "PluginDir+check_edir_time" ]
command = [ PluginDir + "/sudo", "check_edir_time" ]
....
Things would be easier if I could simply select a commandtype ' sudo Plugin Check Command' or select a checkbox 'Run as (sudo)' with perhaps a field for a sudo username in the 'new command' dialog.
In both cases director could use PluginDir as constant in the commands without side effects to generate the expected code:
command = [ "sudo", PluginDir + "/check_edir_time" ]
Regards
Berthold Cogel
The text was updated successfully, but these errors were encountered: