Input.exec not running bash script

Hi, I deployed tick stack in docker. I configured telegraf.conf file to take some metrics from [[input.exec plugin]]. Here is my bash script
#!/bin/sh
cat /proc/uptime | perl -ne ‘/(\d*)/ ; printf “%02d:%02d:%02d:%02d\n”,int($1/86400),int(($1%86400)/3600),int(($1%3600)/60),$1%60’

It is running from terminal but not from telegraf.
please help me to solve this issue

hi @pbsopankar welcome ,

it can be a permission problem ,
can you run the script with the telegraf user ?

best regards ,
Marc

yeah the script runs with telegraf user. But not from telegraf.conf it is giving an error

2019-05-10T13:54:08Z E! [inputs.influxdb]: Error in plugin: [url=http://10.195.182.27:8086/debug/vars]: Get http://10.195.182.27:8086/debug/vars: dial tcp 10.195.182.27:8086: connect: no route to host
2019-05-10T13:54:05Z E! [inputs.exec]: Error in plugin: metric parse error: expected tag at 1:12: “00:08:27:13”

This is my telegraf.conf file

[[inputs.exec]]

## Commands array

commands = [“sh /etc/telegraf/newuptime.sh”]

## Timeout for each command to complete.

timeout = “5s”

## measurement name suffix (for separating different commands)

name_suffix = “_mycollector”

## Data format to consume.

## Each data format has its own unique set of configuration options, read

## more about them here:

## telegraf/DATA_FORMATS_INPUT.md at master · influxdata/telegraf · GitHub

data_format = “influx”

Hi @pbsopankar ,

the bash script should return the output in the line protocol format …

the error : metric parse error: expected tag at 1:12: “00:08:27:13” tells that the format of the output
is not ok.

i have same issue

bash expire.sh 
jks_cert,source=ESB,CN=Sattelite expire-date=1657324799

also when i ran telegraf --config /etc/telegraf/telegraf.conf test data properly writes to InfluxDB.

but if run with service telegraf status it’s showing

Jul 02 11:09:30 localhost.localdomain telegraf[10015]: 2020-07-02T15:09:30Z E! [inputs.exec] Error in plugin: metric parse error: expected tag at 1:9: "31104000"

I have the same error for my bash script too? Any idea how to resolve the same.