diff --git a/cmd/kvmprofiler/config.go b/cmd/kvmprofiler/config.go index 86289d9..0dc736f 100644 --- a/cmd/kvmprofiler/config.go +++ b/cmd/kvmprofiler/config.go @@ -3,6 +3,8 @@ package main import ( "fmt" "os" + "strconv" + "strings" "github.com/cha87de/kvmtop/collectors/cpucollector" "github.com/cha87de/kvmtop/collectors/iocollector" @@ -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 + } diff --git a/config/profiler.go b/config/profiler.go index ea2b9ba..9e9028b 100644 --- a/config/profiler.go +++ b/config/profiler.go @@ -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 } diff --git a/profiler/profiler.go b/profiler/profiler.go index ccfe1d9..510b81d 100644 --- a/profiler/profiler.go +++ b/profiler/profiler.go @@ -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, }) }