Skip to content

Cannot get smart plugin to work with passwordless sudo #8690

Description

@courtarro

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/smartbugunexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions