github.com/vmware/govmomi@v0.37.2/govc/test/metric.bats (about)

     1  #!/usr/bin/env bats
     2  
     3  load test_helper
     4  
     5  @test "metric.ls" {
     6    vcsim_env -esx
     7  
     8    run govc metric.ls
     9    assert_failure
    10  
    11    run govc metric.ls enoent
    12    assert_failure
    13  
    14    host=$(govc ls -t HostSystem ./... | head -n 1)
    15    pool=$(govc ls -t ResourcePool ./... | head -n 1)
    16    vm=$(govc ls -t VirtualMachine ./... | head -n 1)
    17  
    18    run govc metric.ls "$host"
    19    assert_success
    20  
    21    run govc metric.ls -json "$host"
    22    assert_success
    23  
    24    run govc metric.ls "$pool"
    25    assert_success
    26  
    27    run govc metric.ls "$vm"
    28    assert_success
    29  }
    30  
    31  @test "metric.sample" {
    32    vcsim_env
    33  
    34    host=$(govc ls -t HostSystem ./... | head -n 1)
    35    metrics=($(govc metric.ls "$host"))
    36  
    37    run govc metric.sample "$host" enoent
    38    assert_failure
    39  
    40    run govc metric.sample "$host" "${metrics[@]}"
    41    assert_success
    42  
    43    run govc metric.sample -instance - "$host" "${metrics[@]}"
    44    assert_success
    45  
    46    run govc metric.sample -json "$host" "${metrics[@]}"
    47    assert_success
    48  
    49    vm=vm/DC0_H0_VM0
    50  
    51    metrics=($(govc metric.ls "$vm"))
    52  
    53    run govc metric.sample -i day "$vm" "${metrics[@]}"
    54    assert_success
    55  
    56    run govc metric.sample -i 300 -json "$vm" "${metrics[@]}"
    57    assert_success
    58  
    59    run govc metric.sample $vm "${metrics[@]}"
    60    assert_success
    61  }
    62  
    63  @test "metric.info" {
    64    vcsim_env
    65  
    66    host=$(govc ls -t HostSystem ./... | head -n 1)
    67    metrics=($(govc metric.ls "$host"))
    68  
    69    run govc metric.info "$host" enoent
    70    assert_failure
    71  
    72    run govc metric.info "$host"
    73    assert_success
    74  
    75    run govc metric.info -json "$host"
    76    assert_success
    77  
    78    run govc metric.info -dump "$host"
    79    assert_success
    80  
    81    run govc metric.sample "$host" "${metrics[@]}"
    82    assert_success
    83  
    84    run govc metric.info "$host" "${metrics[@]}"
    85    assert_success
    86  
    87    run govc metric.info - "${metrics[@]}"
    88    assert_success
    89  }
    90  
    91  @test "metric manager" {
    92    vcsim_env
    93  
    94    moid=$(govc object.collect -s - content.perfManager)
    95  
    96    govc object.collect -json "$moid" | jq .
    97  }