write stats to influxdb
This commit is contained in:
parent
494696c336
commit
a03057fe81
2 changed files with 22 additions and 4 deletions
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
const (
|
||||
_VERSION = "v1.1.1"
|
||||
_VERSION = "v1.2.0"
|
||||
_tformat = "2006-01-02"
|
||||
_24h = (time.Hour * 23) + (time.Minute * 59) + (time.Second * 59)
|
||||
_10m = (time.Minute * 10)
|
||||
|
@ -44,6 +44,14 @@ func main() {
|
|||
os.Exit(0)
|
||||
}
|
||||
|
||||
if opts.Hostname == "" {
|
||||
var err error
|
||||
opts.Hostname, err = os.Hostname()
|
||||
if err != nil {
|
||||
fmt.Println("Hostname error: ", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
fs, err := os.OpenFile(opts.LogFile, os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0666)
|
||||
if err != nil {
|
||||
fmt.Println("Log file error: ", err.Error())
|
||||
|
@ -100,6 +108,12 @@ func main() {
|
|||
log.Printf("Stop %s: %s\n", ys[i], time.Since(pStart))
|
||||
}
|
||||
|
||||
fmt.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", countOK, countTOT, time.Since(start))
|
||||
log.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", countOK, countTOT, time.Since(start))
|
||||
stop := time.Since(start)
|
||||
|
||||
fmt.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", countOK, countTOT, stop)
|
||||
log.Printf("Stop: OK: %d - TOT: %d - Time: %s\n\r", countOK, countTOT, stop)
|
||||
|
||||
if opts.Influxdb != "" {
|
||||
writeStats(start, stop)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue