Reputation: 2514
I have a sensu client, I debugged its PATH in one of my check script, and it shows:
/sbin:/usr/sbin:/bin:/usr/bin:/etc/sensu/plugins:/etc/sensu/handlers
How can I customize this PATH for sensu, say: I want to add /usr/local/bin to the end of the PATH, which results in: /sbin:/usr/sbin:/bin:/usr/bin:/etc/sensu/plugins:/etc/sensu/handlers:/usr/local/bin
I've tried many ways but didn't success, I've tried:
export PATH=$PATH:/usr/local/bin
PATH=$PATH:/usr/local/bin
USER=ec2-user
in /etc/default/sensu, after restarting sensu client, I clearly see the sensu client process is running by ec2-user, however, surprisingly, the PATH is NOT the same as ec2-userAll 1,2 and 3 above didn't work, in my check script written in python, I have those lins:
from subprocess import call, Popen, PIPE
import os
import sys
import shlex
import platform
print os.environ["PATH"]
proc = Popen(['which', 'python'],
stdout=PIPE,
stderr=PIPE)
out, err = proc.communicate() #does not return until the process has terminated.
print(out)
print(err)
#print(platform.__dict__)
print(platform.python_version())
proc = Popen(['whoami'],
stdout=PIPE,
stderr=PIPE)
out, err = proc.communicate() #does not return until the process has terminated.
print(out)
print(err)
sys.exit(0)
The output was:
/sbin:/usr/sbin:/bin:/usr/bin:/etc/sensu/plugins:/etc/sensu/handlers
/usr/bin/python
2.6.6
ec2-user
Update, while I wrote this line in my python check script:
proc = Popen(['bash','--login', '-x'], stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
print(out)
print(err)
I saw it output:
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/etc/sensu/plugins:/etc/sensu/handlers:/usr/local/sbin:/usr/local/bin
However, the other output surprisingly.... "which python" -> /usr/bin/python, "python --version" -> 2.6.6
Request help....
Upvotes: 0
Views: 402
Reputation: 26
Add the following line
in "/etc/sysconfig/sensu-client". Create the file if not there. Restart your client and your path will be updated.
Upvotes: 0
Reputation: 45333
So do you try to add the PATH in /etc/default/sensu
PATH=$PATH:/usr/local/bin
https://github.com/sensu/sensu-build/blob/master/sensu_configs/upstart/sensu-client.conf#L30
. /etc/default/sensu
will make it work.
Upvotes: 0