From 28ad7c687bac2226a1e66a32f631e73a31851a73 Mon Sep 17 00:00:00 2001 From: Edd Robinson Date: Wed, 18 May 2016 16:04:50 +0100 Subject: [PATCH] Add const for interval --- CHANGELOG.md | 2 ++ tsdb/shard.go | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dee92e470..c81a8b474f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ - [#6519](https://github.com/influxdata/influxdb/issues/6519): Support cast syntax for selecting a specific type. - [#6654](https://github.com/influxdata/influxdb/pull/6654): Add new HTTP statistics to monitoring +- [#6664](https://github.com/influxdata/influxdb/pull/6664): Adds monitoring statistic for on-disk shard size. + ### Bugfixes - [#6604](https://github.com/influxdata/influxdb/pull/6604): Remove old cluster code diff --git a/tsdb/shard.go b/tsdb/shard.go index c68c2f84b9..95a2fab997 100644 --- a/tsdb/shard.go +++ b/tsdb/shard.go @@ -23,6 +23,10 @@ import ( internal "github.com/influxdata/influxdb/tsdb/internal" ) +// monitorStatInterval is the interval at which the shard is inspected +// for the purpose of determining certain monitoring statistics. +const monitorStatInterval = 30 * time.Second + const ( statWriteReq = "writeReq" statSeriesCreate = "seriesCreate" @@ -228,9 +232,9 @@ func (s *Shard) closed() bool { // DiskSize returns the size on disk of this shard func (s *Shard) DiskSize() (int64, error) { var size int64 - err := filepath.Walk(s.path, func(_ string, info os.FileInfo, err error) error { - if !info.IsDir() { - size += info.Size() + err := filepath.Walk(s.path, func(_ string, fi os.FileInfo, err error) error { + if !fi.IsDir() { + size += fi.Size() } return err }) @@ -238,9 +242,9 @@ func (s *Shard) DiskSize() (int64, error) { return 0, err } - err = filepath.Walk(s.walPath, func(_ string, info os.FileInfo, err error) error { - if !info.IsDir() { - size += info.Size() + err = filepath.Walk(s.walPath, func(_ string, fi os.FileInfo, err error) error { + if !fi.IsDir() { + size += fi.Size() } return err }) @@ -606,7 +610,7 @@ func (s *Shard) CreateSnapshot() (string, error) { } func (s *Shard) monitorSize() { - t := time.NewTicker(10 * time.Second) + t := time.NewTicker(monitorStatInterval) defer t.Stop() for { select { @@ -615,7 +619,7 @@ func (s *Shard) monitorSize() { case <-t.C: size, err := s.DiskSize() if err != nil { - s.logger.Printf("error collecting shard size: %v", err) + s.logger.Printf("Error collecting shard size: %v", err) continue } sizeStat := new(expvar.Int)