I'm unable to get the smart plugin to work with a locally-built and installed version of smartmontools using sudo. My telegraf runs as its own user (telegraf), and I've got a sudoers clause set up to enable passwordless execution of /usr/local/sbin/smartctl by Telegraf, yet I get an error.
The log entries are visible below. I think the key message is "sudo: unable to change to root gid: Operation not permitted". I don't understand what this means or why it's appearing. When I manually run sudo -u telegraf to impersonate Telegraf, I'm able to run sudo -n /usr/local/sbin/smartctl --scan just fine, no password needed. Any idea what might be wrong with my configuration?
Relevant telegraf.conf:
[[inputs.smart]]
path = "/usr/local/sbin/smartctl"
use_sudo = true
Relevant sudoers entries:
Cmnd_Alias SMARTCTL = /usr/local/sbin/smartctl
telegraf ALL=(ALL) NOPASSWD: SMARTCTL
Defaults!SMARTCTL !logfile, !syslog, !pam_session
System info:
Running Telegraf version 1.13.0-1 for Ubuntu Bionic (18.04)
Expected behavior:
Telegraf runs smartctl and gathers the relevant metrics.
Actual behavior:
Telegraf fails and the following log entries appear in its systemd log:
Jan 13 16:37:30 prismo telegraf[2893]: 2021-01-13T21:37:30Z E! [inputs.smart] Error in plugin: failed to run command '/usr/local/sbin/smartctl --scan': exit status 1 - sudo: unable to change to root gid: Operation not permitted
Jan 13 16:37:30 prismo telegraf[2893]: sudo: unable to initialize policy plugin
I'm unable to get the
smartplugin to work with a locally-built and installed version ofsmartmontoolsusingsudo. Mytelegrafruns as its own user (telegraf), and I've got asudoersclause set up to enable passwordless execution of/usr/local/sbin/smartctlby Telegraf, yet I get an error.The log entries are visible below. I think the key message is "sudo: unable to change to root gid: Operation not permitted". I don't understand what this means or why it's appearing. When I manually run
sudo -u telegrafto impersonate Telegraf, I'm able to runsudo -n /usr/local/sbin/smartctl --scanjust fine, no password needed. Any idea what might be wrong with my configuration?Relevant
telegraf.conf:Relevant
sudoersentries:System info:
Running Telegraf version
1.13.0-1for Ubuntu Bionic (18.04)Expected behavior:
Telegraf runs
smartctland gathers the relevant metrics.Actual behavior:
Telegraf fails and the following log entries appear in its
systemdlog: