Exit status 127 for command but run as telegraf user works

telegraf
#1

Trying to get metrics from a oracle db.

When I run sudo -u telegraf /opt/telegraf/oracle_metrics.sh

I get
> ORACLE_HOME = /u01/app/oracle/product/11.2.0/xe/

PATH = /u01/app/oracle/product/11.2.0/xe/bin:/sbin:/bin:/usr/sbin:/usr/bin
LD_LIBRARY_PATH = /usr/lib/oracle/12.2/client64/lib:
oracle_wait_class,host=sauron,db=XE,wait_class=Application wait_value=0
oracle_wait_class,host=sauron,db=XE,wait_class=CPU wait_value=0
oracle_wait_class,host=sauron,db=XE,wait_class=CPU_OS wait_value=0.012
oracle_wait_class,host=sauron,db=XE,wait_class=Commit wait_value=0
oracle_wait_class,host=sauron,db=XE,wait_class=Concurrency wait_value=0
oracle_wait_class,host=sauron,db=XE,wait_class=Network wait_value=0
oracle_wait_class,host=sauron,db=XE,wait_class=Other wait_value=0
oracle_wait_class,host=sauron,db=XE,wait_class=Scheduler wait_value=0
oracle_wait_class,host=sauron,db=XE,wait_class=System_I/O wait_value=0
oracle_wait_class,host=sauron,db=XE,wait_class=User_I/O wait_value=0
oracle_wait_event,host=sauron,db=XE,wait_class=System_I/O,wait_event=control_file_sequential_read count=57,latency=0.008
oracle_wait_event,host=sauron,db=XE,wait_class=System_I/O,wait_event=log_file_parallel_write count=1,latency=0.483
oracle_wait_event,host=sauron,db=XE,wait_class=System_I/O,wait_event=control_file_parallel_write count=34,latency=0.543

But when run via telegraf with config

[[inputs.exec]]
commands = ["/opt/telegraf/oracle_metrics.sh"]
data_format = "influx"
interval = “60s”

I get

2017-09-12T03:22:40Z E! Error in plugin [inputs.exec]: exec: exit status 127 for command '/opt/telegraf/oracle_metrics.sh’
2017-09-12T03:23:40Z E! Error in plugin [inputs.exec]: exec: exit status 127 for command ‘/opt/telegraf/oracle_metrics.sh’

-bash-4.2$ telegraf -version
Telegraf v1.4.0 (git: release-1.4 34b7a4c3611d1ede908ef275401544c34a4a3ba3)

Running on centos 7

Any tips ?

#2

Status 127 often means the file wasn’t found or couldn’t be loaded. I see you have some changes to PATH and LD_LIBRARY_PATH, maybe these are not set correctly when being ran as a service?

#3

I am looking for a input for telegraf to collect the data from oracle. Is it some custom code that executes java code to retrieve the data from oracle ? Would you mind sharing it? Thank you