Skip to content

Commit

Permalink
Merge pull request #39 from miken32/miken32-patch-1
Browse files Browse the repository at this point in the history
Allow a multiplier to be set
  • Loading branch information
Hayato Matsuura committed Mar 26, 2018
2 parents 491d46d + 62fd137 commit d2360ec
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion rrdserver.go
Expand Up @@ -94,6 +94,7 @@ type ServerConfig struct {
IpAddr string
Port int
AnnotationFilePath string
Multiplier int
}

type ErrorResponse struct {
Expand Down Expand Up @@ -201,7 +202,8 @@ func query(w http.ResponseWriter, r *http.Request) {
for i := 0; i < fetchRes.RowCnt-1; i++ {
value := fetchRes.ValueAt(dsIndex, i)
if !math.IsNaN(value) {
points = append(points, []float64{value, float64(timestamp.Unix()) * 1000})
product := float64(config.Server.Multiplier) * value
points = append(points, []float64{product, float64(timestamp.Unix()) * 1000})
}
timestamp = timestamp.Add(fetchRes.Step)
}
Expand Down Expand Up @@ -269,6 +271,7 @@ func SetArgs() {
flag.StringVar(&config.Server.RrdPath, "r", "./sample/", "Path for a directory that keeps RRD files.")
flag.IntVar(&config.Server.Step, "s", 10, "Step in second.")
flag.StringVar(&config.Server.AnnotationFilePath, "a", "", "Path for a file that has annotations.")
flag.IntVar(&config.Server.Multiplier, "m", 1, "Value multiplier.")
flag.Parse()
}

Expand Down

0 comments on commit d2360ec

Please sign in to comment.