telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

can we use powershell script in telegraf?

Open maddygoes opened this issue 10 years ago • 7 comments

[[inputs.exec]] commands = ["D:\Tealeaf\System\canisterstats.ps1"] timeout = "30s" data_format = "influx" name_suffix = "_expPlusCan"

am getting below error : C:\Program Files\Telegraf>telegraf -config telegraf.conf -test Error parsing telegraf.conf, toml: line 131: parse error

this is line 131 -- commands = ["D:\Tealeaf\System\canisterstats.ps1"]

maddygoes avatar Nov 11 '16 08:11 maddygoes

You need to escape your backslash in your commands path. Use double backslash instead \\

commands = ["D:\\Tealeaf\\System\\canisterstats.ps1"]

puckpuck avatar Nov 12 '16 04:11 puckpuck

Thanks puckpuck.. Still error.. changed from ps1 to bat :-(

[[inputs.exec]] commands = ["D:\Tealeaf\System\canstat.bat"] timeout = "30s" data_format = "json" name_suffix = "_expPlusCan"

2016/11/12 04:39:53 Errors encountered: [exec: exec: "D:TealeafSystemcanstat.bat ": file does not exist for command 'D:\Tealeaf\System\canstat.bat']

maddygoes avatar Nov 12 '16 12:11 maddygoes

commands = ["D:/\Tealeaf/\System/\canstat.bat"] --- this one working !!!

Thanks for showing me a way ;-)

maddygoes avatar Nov 12 '16 12:11 maddygoes

I am having the same issue: In my case PS C:\Program Files\telegraf> .\telegraf.exe -config telegraf.conf -test 2017/03/23 17:48:50 E! Error parsing telegraf.conf, toml: line 179: parse error

And this is line 179: commands = ["C:/\process.bat"] I've tried commands = ["C:\process.bat"] as well and same issue.

mananpatel avatar Mar 23 '17 17:03 mananpatel

@mananpatel Please take a look at this issue: #2230

danielnelson avatar Mar 23 '17 18:03 danielnelson

@danielnelson Thanks. That worked lake a charm.

mananpatel avatar Mar 24 '17 11:03 mananpatel

Try like this, i has the same issue and use '/' instead of '\' or '\\', it works.

[[inputs.exec]] commands = ["D:/Tealeaf/System/canisterstats.ps1"] timeout = "30s" data_format = "influx" name_suffix = "_expPlusCan"

dogyy0119 avatar Jan 31 '18 02:01 dogyy0119