-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't start Telegraf Service Inputs.exec Linux #6028
Comments
Hey @raider111111 , would you try escaping the double quotes like this: commands = ["telegraf --version | awk '{print($2)}' | awk -F '.' '{print($1\".\"$2)}'"] |
That worked! Thanks! |
Hi! That worked but for some reason it isn't sending the data correctly. Here's my config:
I'm just trying to send only the Telegraf version number out without the second period, like this:"1.11". Error from the log: Any idea? |
Hey @raider111111 , because your data_type is What is the output of your command now? I suspect you have the SHA in there as well. The resolution will likely be to change the datatype to something other than an integer. |
Hi @goller , Here is what I see: Float: |
Yes, I read that as telegraf is not able to parse your awk output as either a pure float or integer. Your string example looks like it is running Atoi (that'd be converting the output to an integer). What is the output of the command line when you run it outside of telegraf? |
1.11 |
Well, actually it doesn't work with your edits, but I've encountered Telegraf parsing commands differently so I assumed that was probably fine. Your edit:
Original:
Do you suggest I run a different command? |
yes, my edits with the escaping of " are only applicable in the telegraf TOML. Those escapes would not be needed when running from the CLI. try this: [[inputs.exec]]
## Commands array
commands = ["sh -c \"telegraf --version | awk '{print($2)}' | awk -F '.' '{print($1\".\"$2)}'\""]
## Timeout for each command to complete.
## Timeout for each command to complete.
timeout = "5s"
## measurement name suffix (for separating different commands)
#name_suffix = "_mycollector"
name_override = "TelegrafVersion"
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "value"
data_type = "integer"
I don't believe telegraf supports piping without it being in a single shell command. This config gives me: telegraf --test --config howdy.conf
2019-06-21T17:41:19Z I! Starting Telegraf 1.11.0
> TelegrafVersion,host=ip-192-168-194-137.ec2.internal value=111i 1561138879000000000 |
Sure thing! That looks better, though I lose the period in the 1.11.
Any way to get that . back so it's 1.11? |
Yup, so, we can't use an integer in this case, so, you'll need to doubly escape the period and use a string: [[inputs.exec]]
## Commands array
commands = ["sh -c \"telegraf --version | awk '{print($2)}' | awk -F '.' '{print($1\\\".\\\"$2)}'\""]
## Timeout for each command to complete.
## Timeout for each command to complete.
timeout = "5s"
## measurement name suffix (for separating different commands)
#name_suffix = "_mycollector"
name_override = "TelegrafVersion"
## Data format to consume.
## Each data format has its own unique set of configuration options, read
## more about them here:
## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
data_format = "value"
data_type = "string"
telegraf --test --config howdy.conf
2019-06-21T17:51:58Z I! Starting Telegraf 1.11.0
> TelegrafVersion,host=ip-192-168-194-137.ec2.internal value="1.11" 1561139519000000000
|
I'm trying that out. So, that came out correctly except that the monitoring appliance doesn't accept strings.
|
@raider111111 1.11 could be formatted as a float, yes. Try |
That did it! Adding the end result.
Thanks for your help friend! |
Keep an eye on #5958 too, I think it also will do essentially what you want. |
@danielnelson Nice!! |
@goller I am Having similar issue but i am using python script, which runs on a file and produce the value, I have issue with the output see: [inputs.exec] Error in plugin: strconv.Atoi: parsing "forcepoint=0.04563498497009277": invalid syntax |
@gmigiro probably best to open a new issue; my instinct is that you need to specify data_type = "float" as @raider111111 did above. |
Relevant telegraf.conf:
System info:
Steps to reproduce:
Expected behavior:
Display Telegraf version number
Actual behavior:
Process fails to start
Additional info:
Failed to start The plugin-driven server agent for reporting metrics into InfluxDB.
Command executes sucessfully in the terminal:
telegraf --version | awk '{print($2)}' | awk -F '.' '{print($1"."$2)}'
1.11
This is probably just formatting but I'm not sure what I'm doing wrong.
The text was updated successfully, but these errors were encountered: