Skip to content

Commit

Permalink
Add doc on metric.sample instance flag (#726)
Browse files Browse the repository at this point in the history
  • Loading branch information
dougm authored May 26, 2017
1 parent 8bff835 commit 67b13b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 11 additions & 1 deletion govc/metric/sample.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ func (cmd *sample) Description() string {
Interval ID defaults to 20 (realtime) if supported, otherwise 300 (5m interval).
By default, INSTANCE '*' samples all instances and the aggregate counter.
An INSTANCE value of '-' will only sample the aggregate counter.
An INSTANCE value other than '*' or '-' will only sample the given instance counter.
If PLOT value is set to '-', output a gnuplot script. If non-empty with another
value, PLOT will pipe the script to gnuplot for you. The value is also used to set
the gnuplot 'terminal' variable, unless the value is that of the DISPLAY env var.
Expand All @@ -77,7 +81,9 @@ Only 1 metric NAME can be specified when the PLOT flag is set.
Examples:
govc metric.sample host/cluster1/* cpu.usage.average
govc metric.sample -plot .png host/cluster1/* cpu.usage.average | xargs open
govc metric.sample vm/* net.bytesTx.average net.bytesTx.average`
govc metric.sample vm/* net.bytesTx.average net.bytesTx.average
govc metric.sample -instance vmnic0 vm/* net.bytesTx.average
govc metric.sample -instance - vm/* net.bytesTx.average`
}

func (cmd *sample) Process(ctx context.Context) error {
Expand Down Expand Up @@ -294,6 +300,10 @@ func (cmd *sample) Run(ctx context.Context, f *flag.FlagSet) error {
return err
}

if cmd.instance == "-" {
cmd.instance = ""
}

spec := types.PerfQuerySpec{
Format: string(types.PerfFormatNormal),
MaxSample: int32(cmd.n),
Expand Down
3 changes: 3 additions & 0 deletions govc/test/metric.bats
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ load test_helper
run govc metric.sample "$host" "${metrics[@]}"
assert_success

run govc metric.sample -instance - "$host" "${metrics[@]}"
assert_success

run govc metric.sample -json "$host" "${metrics[@]}"
assert_success

Expand Down

0 comments on commit 67b13b5

Please sign in to comment.