[英]Creating a tty for Sensu with Python
Hello guys I'm trying to create a sensu check in python that requires a shell but is currently giving me a tty error. 大家好,我正在尝试在需要外壳的python中创建sensu检查,但目前却给我一个tty错误。
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 默认情况下,Sensu没有tty,因此在尝试执行脚本时
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 我已经有以下sudo规则
Cmnd_Alias DRIVE_AUTOMATION=/apptio/scripts/diskauto.py
You can configure sudo
to not require a tty for certain cases. 您可以将
sudo
配置为在某些情况下不需要tty。
Assuming sensu
is running as the sensu
user, add the following to /etc/sudoers
: 假设
sensu
以sensu
用户身份运行,则将以下内容添加到/etc/sudoers
:
Defaults:sensu !requiretty
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.