diff --git a/main.go b/main.go index 08c0e24..3f58e99 100644 --- a/main.go +++ b/main.go @@ -38,11 +38,6 @@ import ( "gopkg.in/alecthomas/kingpin.v2" ) -// timeout specifies the number of iterations after which a metric times out, -// i.e. becomes stale and is removed from collectdCollector.valueLists. It is -// modeled and named after the top-level "Timeout" setting of collectd. -const timeout = 2 - var ( listenAddress = kingpin.Flag("web.listen-address", "Address on which to expose metrics and web interface.").Default(":9103").String() collectdAddress = kingpin.Flag("collectd.listen-address", "Network address on which to accept collectd binary network packets, e.g. \":25826\".").Default("").String() @@ -50,6 +45,7 @@ var ( collectdAuth = kingpin.Flag("collectd.auth-file", "File mapping user names to pre-shared keys (passwords).").Default("").String() collectdSecurity = kingpin.Flag("collectd.security-level", "Minimum required security level for accepted packets. Must be one of \"None\", \"Sign\" and \"Encrypt\".").Default("None").String() collectdTypesDB = kingpin.Flag("collectd.typesdb-file", "Collectd types.db file for datasource names mapping. Needed only if using a binary network protocol.").Default("").String() + collectdTimeout = kingpin.Flag("collectd.timeout", "Specifies the number of iterations after which a metric times out and is removed from collectdCollector.valueLists.").Default("2").Uint64() metricsPath = kingpin.Flag("web.telemetry-path", "Path under which to expose Prometheus metrics.").Default("/metrics").String() collectdPostPath = kingpin.Flag("web.collectd-push-path", "Path under which to accept POST requests from collectd.").Default("/collectd-post").String() lastPush = prometheus.NewGauge( @@ -59,6 +55,11 @@ var ( }, ) metric_name_re = regexp.MustCompile("[^a-zA-Z0-9_:]") + + // timeout specifies the number of iterations after which a metric times out, + // i.e. becomes stale and is removed from collectdCollector.valueLists. It is + // modeled and named after the top-level "Timeout" setting of collectd. + timeout time.Duration ) // newName converts one data source of a value list to a string representation. @@ -314,6 +315,8 @@ func main() { flag.AddFlags(kingpin.CommandLine, promlogConfig) kingpin.HelpFlag.Short('h') kingpin.Parse() + + timeout = time.Duration(*collectdTimeout) logger := promlog.New(promlogConfig) kingpin.Version(version.Print("collectd_exporter"))