set influxdb fields time to "start" time

This commit is contained in:
Miki 2016-02-18 13:36:33 +01:00
parent 98226a042a
commit 5ef381fd79
2 changed files with 5 additions and 4 deletions

View file

@ -3,11 +3,12 @@ package main
import ( import (
"fmt" "fmt"
"time"
influxdb "github.com/influxdata/influxdb/client/v2" influxdb "github.com/influxdata/influxdb/client/v2"
) )
func writeStats() { func writeStats(start time.Time) {
if opts.Debug { if opts.Debug {
fmt.Printf("writing to influxdb server: %s", opts.Influxdb) fmt.Printf("writing to influxdb server: %s", opts.Influxdb)
} }
@ -39,7 +40,7 @@ func writeStats() {
"dup": count.GetDup(), "dup": count.GetDup(),
"stop": count.GetTime(), "stop": count.GetTime(),
} }
pt, err := influxdb.NewPoint("ll2mongo", tags, fields) pt, err := influxdb.NewPoint("ll2mongo", tags, fields, start)
if err != nil { if err != nil {
fmt.Printf("Error: %+v\n", err) fmt.Printf("Error: %+v\n", err)
return return

View file

@ -11,7 +11,7 @@ import (
) )
const ( const (
_VERSION = "v2.5.0" _VERSION = "v2.5.1"
) )
var ( var (
@ -107,7 +107,7 @@ func main() {
log.Printf("Stop %v - user: %d - login: %d - errors: %d - rem: %d - duplicate: %d\n\r", count.GetTime(), count.GetUser(), count.GetLog(), count.GetErr(), count.GetRem(), count.GetDup()) log.Printf("Stop %v - user: %d - login: %d - errors: %d - rem: %d - duplicate: %d\n\r", count.GetTime(), count.GetUser(), count.GetLog(), count.GetErr(), count.GetRem(), count.GetDup())
if opts.Influxdb != "" { if opts.Influxdb != "" {
writeStats() writeStats(start)
} }
if opts.Xymon != "" { if opts.Xymon != "" {