40 lines
951 B
Go
40 lines
951 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"time"
|
|
|
|
_ "git.karaolidis.com/karaolidis/telegraf-clickhouse-plugin/plugins/outputs/clickhouse"
|
|
|
|
"github.com/influxdata/telegraf/plugins/common/shim"
|
|
)
|
|
|
|
var pollInterval = flag.Duration("poll_interval", 1*time.Second, "how often to send metrics")
|
|
var pollIntervalDisabled = flag.Bool(
|
|
"poll_interval_disabled",
|
|
false,
|
|
"set to true to disable polling. You want to use this when you are sending metrics on your own schedule",
|
|
)
|
|
var configFile = flag.String("config", "", "path to the config file for this plugin")
|
|
var err error
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
if *pollIntervalDisabled {
|
|
*pollInterval = shim.PollIntervalDisabled
|
|
}
|
|
|
|
shimLayer := shim.New()
|
|
if err = shimLayer.LoadConfig(configFile); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Err loading input: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
if err = shimLayer.Run(*pollInterval); err != nil {
|
|
fmt.Fprintf(os.Stderr, "Err: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|