Hello guys I'm trying to create a sensu check in python that requires a shell but is currently giving me a tty error.
cmd = '/usr/bin/pstorage stat |grep %s |grep failed' % hostname
output = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()[0]
Sensu by default doesn't have a tty so when it tries to execute the script
sudo /etc/sensu/plugins/diskauto.py --storage_name pool-01
the output is
sudo: no tty present and no askpass program specified
I already have the following sudo rule in place
Cmnd_Alias DRIVE_AUTOMATION=/apptio/scripts/diskauto.py
You can configure sudo
to not require a tty for certain cases.
Assuming sensu
is running as the sensu
user, add the following to /etc/sudoers
:
Defaults:sensu !requiretty
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.