spedisce a influxdb la data
This commit is contained in:
parent
e3d7b1dae5
commit
2e53d3fb4f
2 changed files with 22 additions and 14 deletions
|
@ -11,13 +11,14 @@ import (
|
||||||
type InfluxdbOutput struct {
|
type InfluxdbOutput struct {
|
||||||
CountOK int
|
CountOK int
|
||||||
CountTOT int
|
CountTOT int
|
||||||
|
Start time.Time
|
||||||
Stop time.Duration
|
Stop time.Duration
|
||||||
Pipe time.Duration
|
Pipe time.Duration
|
||||||
Find time.Duration
|
Find time.Duration
|
||||||
Insert time.Duration
|
Insert time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeStats(start time.Time) {
|
func writeStats(start time.Time, ys 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)
|
||||||
}
|
}
|
||||||
|
@ -41,10 +42,11 @@ func writeStats(start time.Time) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
tags := map[string]string{"server": opts.Hostname}
|
tags := map[string]string{"server": opts.Hostname, "date": ys.String()}
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"LoginOK": idb.CountOK,
|
"LoginOK": idb.CountOK,
|
||||||
"LoginTOT": idb.CountTOT,
|
"LoginTOT": idb.CountTOT,
|
||||||
|
"start": ys,
|
||||||
"stop": idb.Stop.Seconds(),
|
"stop": idb.Stop.Seconds(),
|
||||||
"pipe": idb.Pipe.Nanoseconds(),
|
"pipe": idb.Pipe.Nanoseconds(),
|
||||||
"find": idb.Find.Nanoseconds(),
|
"find": idb.Find.Nanoseconds(),
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
_VERSION = "v1.3.0"
|
_VERSION = "v1.3.1"
|
||||||
_tformat = "2006-01-02"
|
_tformat = "2006-01-02"
|
||||||
_24h = (time.Hour * 23) + (time.Minute * 59) + (time.Second * 59)
|
_24h = (time.Hour * 23) + (time.Minute * 59) + (time.Second * 59)
|
||||||
_10m = (time.Minute * 10)
|
_10m = (time.Minute * 10)
|
||||||
|
@ -82,12 +82,14 @@ func main() {
|
||||||
// DEBUG
|
// DEBUG
|
||||||
//fmt.Printf("Start %+v\n\r", y)
|
//fmt.Printf("Start %+v\n\r", y)
|
||||||
|
|
||||||
var ys []time.Time
|
// var ys []time.Time
|
||||||
var ye []time.Time
|
// var ye []time.Time
|
||||||
|
var ys time.Time
|
||||||
|
var ye time.Time
|
||||||
|
|
||||||
// if opts.Duration <= (time.Hour * 24) {
|
// if opts.Duration <= (time.Hour * 24) {
|
||||||
ys = append(ys, time.Date(y.Year(), y.Month(), y.Day(), 0, 0, 0, 0, time.UTC))
|
ys = time.Date(y.Year(), y.Month(), y.Day(), 0, 0, 0, 0, time.UTC)
|
||||||
ye = append(ye, ys[0].Add(opts.Duration))
|
ye = ys.Add(opts.Duration)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
} else {
|
} else {
|
||||||
|
@ -108,15 +110,19 @@ func main() {
|
||||||
fmt.Printf("Start: %+v, Stop: %+v\n\r", ys, ye)
|
fmt.Printf("Start: %+v, Stop: %+v\n\r", ys, ye)
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := range ys {
|
// for i := range ys {
|
||||||
|
|
||||||
pStart := time.Now()
|
pStart := time.Now()
|
||||||
|
|
||||||
aggregate(ys[i], ye[i])
|
// aggregate(ys[i], ye[i])
|
||||||
|
aggregate(ys, ye)
|
||||||
|
|
||||||
fmt.Printf("Stop %s: %s\n", ys[i], time.Since(pStart))
|
fmt.Printf("Stop %s: %s\n", ys, time.Since(pStart))
|
||||||
log.Printf("Stop %s: %s\n", ys[i], time.Since(pStart))
|
log.Printf("Stop %s: %s\n", ys, time.Since(pStart))
|
||||||
}
|
|
||||||
|
// fmt.Printf("Stop %s: %s\n", ys[i], time.Since(pStart))
|
||||||
|
// log.Printf("Stop %s: %s\n", ys[i], time.Since(pStart))
|
||||||
|
// }
|
||||||
|
|
||||||
idb.Stop = time.Since(start)
|
idb.Stop = time.Since(start)
|
||||||
|
|
||||||
|
@ -124,6 +130,6 @@ func main() {
|
||||||
log.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", idb.CountOK, idb.CountTOT, idb.Stop)
|
log.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", idb.CountOK, idb.CountTOT, idb.Stop)
|
||||||
|
|
||||||
if opts.Influxdb != "" {
|
if opts.Influxdb != "" {
|
||||||
writeStats(start)
|
writeStats(start, ys)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue