Hi,
i have a problem to get SmartCTL working in Telegraf in Docker.
What i have done:
Edited sudoers File /etc/sudoers:
# For smartctl add the following lines:
Cmnd_Alias SMARTCTL = /usr/sbin/smartctl
telegraf ALL=(ALL) NOPASSWD: SMARTCTL
Defaults!SMARTCTL !logfile, !syslog, !pam_session
Edited telegraf.conf:
[[inputs.smart]]
path_smartctl = "/usr/sbin/smartctl"
use_sudo = true
attributes = true
In Docker i added this docker-compose.yml:
version: "3.0"
name: "telegraf"
services:
telegraf:
image: telegraf:latest
container_name: telegraf
network_mode: host
privileged: true #for smartctl
environment:
- TZ=Europe/Berlin
- HOST_ETC=/hostfs/etc
- HOST_PROC=/hostfs/proc
- HOST_SYS=/hostfs/sys
- HOST_USR=/hostfs/usr
- HOST_MOUNT_PREFIX=/hostfs
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/docker/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro
- /:/hostfs:ro
- /run/udev:/run/udev:ro
- /usr/sbin:/usr/sbin:ro
logging:
driver: json-file
restart: unless-stopped
I get this Error from the Telegraf Logs:
2025-07-01T12:27:49Z W! [inputs.smart] nvme not found: verify that nvme is installed and it is in your PATH (or specified in config) to gather vendor specific attributes: provided path does not exist: []
2025-07-01T12:28:00Z E! [inputs.smart] Error in plugin: failed to run command '/usr/sbin/smartctl [--scan]': exec: "sudo": executable file not found in $PATH -
Ideas how to get smartctl working ?