【发布时间】:2016-05-25 12:25:57
【问题描述】:
您好,我想知道是否有人准备好了为 Influxdb 添加一个插件到 telegraf。 我有我的运行代码。接下来我需要什么以及将这些文件放在哪里?
我发现我需要做这样的事情:
type ReadFile struct {
//buf []byte
//MemoryBytes int64
//PID int
}
func (s *ReadFile) Description() string {
return "This is a test plugin to read data from a file and send them to influxdb" }
func (s *ReadFile) SampleConfig() string {
return "ok = true # indicate if everything is fine"
}
func Gather(acc plugins.Accumulator) error {
readFile(alarmFile)
acc.Add("alarm", result_of_readFile_here, tags)
}
}
func init() {
plugins.Add("readFile", func() plugins.Plugin { &ReadFile{} })
}
但这是我的整个 Go 插件还是 Go 中要添加到我的 Go 程序中的另一个文件?
file.conf 存储在哪里?
[tags]
dc = "alarm"
[agent]
interval = "10s"
# OUTPUTS
[outputs]
[outputs.influxdb]
url = "http://127.0.0.1:8086" # required.
database = "summer" # required.
precision = "s"
# PLUGINS
[readFile]
如果你有我需要的清单,如何构建它,我存储文件的位置或者一个示例可能真的很有帮助。
谢谢!!
【问题讨论】: