Plugins requiring sudo

Some commands require sudo privileges to run. The agent runs under the user sd-agent which is a regular, unprivileged user which means you need to specifically run commands in your plugin code using sudo.

This article is for our v1 agent and will soon be deprecated.

This can be done using something like subprocess in Python (note: lsof is used as an example so you should replace with the relevant command):

Popen(['sudo', 'lsof', 'arg1', 'arg2'])

You also need to modify the /etc/sudoers (using visudo) file to allow the agent to run this command:

sd-agent ALL=(ALL) NOPASSWD: /usr/sbin/lsof

And finally comment out this line in the sudoers file because the agent does not run with a TTY:

#Defaults    requiretty


Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request


Monday  —  Friday.

10am  —  6pm UK.

Dedicated Support.