diff --git a/cmd/influxd/run.go b/cmd/influxd/run.go index e6e6e57b8e..e333e8933a 100644 --- a/cmd/influxd/run.go +++ b/cmd/influxd/run.go @@ -185,6 +185,7 @@ func Run(config *Config, join, version string, logWriter *os.File) (*messaging.B if config.Statistics.Enabled { database := config.Statistics.Database policy := config.Statistics.RetentionPolicy + interval := time.Duration(config.Statistics.WriteInterval) // Ensure database exists. if err := s.CreateDatabaseIfNotExists(database); err != nil { diff --git a/server.go b/server.go index 9f87c9d43b..cfa17d5f1a 100644 --- a/server.go +++ b/server.go @@ -328,30 +328,20 @@ func (s *Server) StartSelfMonitoring(database, retention string, interval time.D return fmt.Errorf("statistics check interval must be non-zero") } - // Grab the initial stats. - prev := s.stats.Snapshot() - go func() { for { time.Sleep(interval) - // Grab the current stats and diff them. - stats := s.stats.Snapshot() - diff := stats.Diff(prev) - // Create the data point and write it. point := Point{ - Name: diff.Name(), + Name: s.stats.Name(), Tags: map[string]string{"id": strconv.FormatUint(s.id, 10)}, Fields: make(map[string]interface{}), } - diff.Walk(func(k string, v int64) { - point.Fields[k] = v + s.stats.Walk(func(k string, v int64) { + point.Fields[k] = int(v) }) s.WriteSeries(database, retention, []Point{point}) - - // Save stats for the next loop. - prev = stats } }()