Skip to content

Commit

Permalink
Dump all values from all archives.
Browse files Browse the repository at this point in the history
  • Loading branch information
bzed committed Mar 30, 2017
1 parent 400c649 commit da9e149
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"errors"
"flag"
"github.com/lomik/go-whisper"
"github.com/bzed/go-whisper"
"github.com/marpaia/graphite-golang"
"log"
"math"
Expand All @@ -12,7 +12,6 @@ import (
"strconv"
"strings"
"sync"
"time"
)

func convertFilename(filename string, baseDirectory string) (string, error) {
Expand Down Expand Up @@ -58,34 +57,26 @@ func sendWhisperData(
return err
}

timeSeriesdata, err := whisperData.Fetch(whisperData.StartTime(), int(time.Now().Unix()))
archiveDataPoints, err := whisperData.DumpArchives()
if err != nil {
return err
}
metrics := make([]graphite.Metric, 0, 1000)
for _, dataPoint := range archiveDataPoints {
interval, value := dataPoint.Point()

point_count := 0
metrics := make([]graphite.Metric, 1000)
for _, point := range timeSeriesdata.Points() {
if math.IsNaN(point.Value) {
if math.IsNaN(value) {
continue
}
v := strconv.FormatFloat(point.Value, 'f', -1, 64)
metrics[point_count] = graphite.NewMetric(metricName, v, int64(point.Time))
point_count++
if point_count >= 1000 {
err = graphiteConn.SendMetrics(metrics)
if err != nil {
return err
}
point_count = 0
metrics = make([]graphite.Metric, 1000)
}

v := strconv.FormatFloat(value, 'f', 20, 64)
metrics = append(metrics, graphite.NewMetric(metricName, v, int64(interval)))

}
err = graphiteConn.SendMetrics(metrics)
if err != nil {
return err
}

err = nil
return err
}
Expand Down

0 comments on commit da9e149

Please sign in to comment.