Skip to content

Commit

Permalink
add periodsize parameter to kvmprofiler
Browse files Browse the repository at this point in the history
  • Loading branch information
cha87de committed Feb 21, 2019
1 parent f853bac commit 39820c3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
14 changes: 14 additions & 0 deletions cmd/kvmprofiler/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package main
import (
"fmt"
"os"
"strconv"
"strings"

"github.com/cha87de/kvmtop/collectors/cpucollector"
"github.com/cha87de/kvmtop/collectors/iocollector"
Expand Down Expand Up @@ -55,4 +57,16 @@ func initializeFlags() {
fmt.Println("host profiling not supported.")
}

// Parse periodsize csv string
periodSizeStr := strings.Split(config.Options.Profiler.PeriodSize, ",")
periodSize := make([]int, 0)
for _, s := range periodSizeStr {
if s == "" {
continue
}
si, _ := strconv.Atoi(s)
periodSize = append(periodSize, si)
}
config.Options.Profiler.PeriodSizeParsed = periodSize

}
5 changes: 4 additions & 1 deletion config/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ type ProfilerOptionsType struct {
BufferSize int `long:"buffersize" default:"10"`
History int `long:"history" default:"1"`
FilterStdDevs int `long:"filterstddevs" default:"-1"`
OutputFreq time.Duration `long:"outputFreq" default:"60"`
FixedBound bool `long:"fixedbound"`
PeriodSize string `long:"periodsize" default:"" description:"comma separated list of ints, specifies descrete states per period"`
OutputFreq time.Duration `long:"outputFreq" default:"60"`

PeriodSizeParsed []int
}
2 changes: 1 addition & 1 deletion profiler/profiler.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func pickup() {
FixBound: config.Options.Profiler.FixedBound,
OutputFreq: config.Options.Profiler.OutputFreq,
OutputCallback: profileOutput,
PeriodSize: []int{6, 60}, // 1min, 1h
PeriodSize: config.Options.Profiler.PeriodSizeParsed,
})
}

Expand Down

0 comments on commit 39820c3

Please sign in to comment.