Report anonymous stats to Enterprise

pull/4683/head
Mark Bates 2015-11-06 10:30:57 -05:00
parent 377d926aba
commit d46bf535b2
1 changed files with 20 additions and 11 deletions

View File

@ -1,17 +1,16 @@
package run package run
import ( import (
"bytes"
"fmt" "fmt"
"log" "log"
"net" "net"
"net/http"
"os" "os"
"runtime" "runtime"
"runtime/pprof" "runtime/pprof"
"strings" "strings"
"time" "time"
"github.com/influxdb/enterprise-client/v1"
"github.com/influxdb/influxdb/cluster" "github.com/influxdb/influxdb/cluster"
"github.com/influxdb/influxdb/meta" "github.com/influxdb/influxdb/meta"
"github.com/influxdb/influxdb/monitor" "github.com/influxdb/influxdb/monitor"
@ -512,18 +511,28 @@ func (s *Server) reportServer() {
return return
} }
json := fmt.Sprintf(`[{ cl := client.New("")
"name":"reports", usage := client.Usage{
"columns":["os", "arch", "version", "server_id", "cluster_id", "num_series", "num_measurements", "num_databases"], Product: "influxdb",
"points":[["%s", "%s", "%s", "%x", "%x", "%d", "%d", "%d"]] Data: []client.UsageData{
}]`, runtime.GOOS, runtime.GOARCH, s.buildInfo.Version, s.MetaStore.NodeID(), clusterID, numSeries, numMeasurements, numDatabases) {
Values: client.Values{
data := bytes.NewBufferString(json) "os": runtime.GOOS,
"arch": runtime.GOARCH,
"version": s.buildInfo.Version,
"server_id": s.MetaStore.NodeID(),
"cluster_id": clusterID,
"num_series": numSeries,
"num_measurements": numMeasurements,
"num_databases": numDatabases,
},
},
},
}
log.Printf("Sending anonymous usage statistics to m.influxdb.com") log.Printf("Sending anonymous usage statistics to m.influxdb.com")
client := http.Client{Timeout: time.Duration(5 * time.Second)} go cl.Save(usage)
go client.Post("http://m.influxdb.com:8086/db/reporting/series?u=reporter&p=influxdb", "application/json", data)
} }
// monitorErrorChan reads an error channel and resends it through the server. // monitorErrorChan reads an error channel and resends it through the server.