1

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
Royce
  • 45
  • 9

1 Answers1

2

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
match
  • 10,388
  • 3
  • 23
  • 41