Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add doc on metric.sample instance flag #726

Merged
merged 1 commit into from
May 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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