File: metric_info_test.sh

package info (click to toggle)
golang-github-vmware-govmomi 0.24.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,848 kB
  • sloc: sh: 2,285; lisp: 1,560; ruby: 948; xml: 139; makefile: 54
file content (20 lines) | stat: -rwxr-xr-x 484 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash -e

types="Datacenter HostSystem ClusterComputeResource ResourcePool VirtualMachine Datastore VirtualApp"

for type in $types ; do
  echo "$type..."

  obj=$(govc ls -t "$type" ./... | head -n 1)
  if [ -z "$obj" ] ; then
    echo "...no instances found"
    continue
  fi

  if ! govc metric.info "$obj" 2>/dev/null ; then
    echo "...N/A" # Datacenter, Datastore on ESX for example
    continue
  fi

  govc metric.ls "$obj" | xargs govc metric.sample -n 5 "$obj"
done