Viewing Usage Statistics for Hosts and Instances

You can view basic statistics on resource usage for hosts and instances using the CLI.

Note For more sophisticated monitoring, including autoscaling; you can create, scale up, or scale down webhooks (user-defined HTTP callbacks) using an Orchestration template. See Implementing Heat Orchestration Templates or see the example in Metacloud: Create an Orchestration Template in the Cisco Learning Labs.

The following examples show the host usage statistics for a host called mhv6.az.metacloud.net.

To show host usage statistics:

  1. List the hosts and their nova-related services.

       $ openstack host list
       +------------------------+-------------+----------+
       | Host Name              | Service     | Zone     |
       +------------------------+-------------+----------+
       | mcp2.az.metacloud.net  | conductor   | internal |
       | mcp3.az.metacloud.net  | conductor   | internal |
       | mcp3.az.metacloud.net  | scheduler   | internal |
       | mcp3.az.metacloud.net  | consoleauth | internal |
       | mcp3.az.metacloud.net  | console     | internal |
       | mcp2.az.metacloud.net  | consoleauth | internal |
       | mcp2.az.metacloud.net  | console     | internal |
       | mcp2.az.metacloud.net  | scheduler   | internal |
       | mcp1.az.metacloud.net  | consoleauth | internal |
       | mcp1.az.metacloud.net  | conductor   | internal |
       | mcp1.az.metacloud.net  | scheduler   | internal |
       | mcp1.az.metacloud.net  | console     | internal |
       | mhv8.az.metacloud.net  | compute     | strat1   |
       | mhv9.az.metacloud.net  | compute     | strat1   |
       | mhv6.az.metacloud.net  | compute     | strat1   |
       | mhv10.az.metacloud.net | compute     | strat1   |
       | mhv7.az.metacloud.net  | compute     | strat1   |
       +------------------------+-------------+----------+
    
  2. Show a summary of resource usage of all of the instances running on the host.

       $ openstack host show mhv6.az.metacloud.net
       +-----------------------+------------+-----+-----------+---------+
       | Host                  | Project    | CPU | Memory MB | Disk GB |
       +-----------------------+------------+-----+-----------+---------+
       | mhv6.az.metacloud.net | (total)    |  32 |    257525 |  446904 |
       | mhv6.az.metacloud.net | (used_now) |   4 |     10240 |      80 |
       | mhv6.az.metacloud.net | (used_max) |   2 |      4096 |      40 |
       | mhv6.az.metacloud.net | 408...9b0  |   2 |      4096 |      40 |
       +-----------------------+------------+-----+-----------+---------+
    
    • Project—shows the sum of allocated resources:
      • used_max—shows the sum of the resources allocated to the instances that run on the host.
      • used_now—shows the sum of the resources allocated to the instances that run on the host, plus the resources allocated to the virtual machine of the host itself.
    • CPU—shows the sum of the virtual CPUs for instances running on the host.
    • Memory MB—shows the sum of the memory in megabytes allocated to the instances that run on the host.
    • Disk GB—shows the sum of the root and ephemeral disk sizes in gigabytes of the instances that run on the host.

Note
These values are computed by using information about the flavors of the instances that run on the hosts. This command does not query the CPU usage, memory usage, or hard disk usage of the physical host.

To show instance usage statistics:

  1. List the server names and note the server name you want statistics for.
  2. Show the specific server for CPU, memory, I/O, and network statistics for an instance.

     $ openstack server show <SERVER_NAME>
    +--------------------------------------+---------------------------------------------------------+
    | Field                                | Value                                                   |
    +--------------------------------------+---------------------------------------------------------+
    | OS-DCF:diskConfig                    | MANUAL                                                  |
    | OS-EXT-AZ:availability_zone          | <AZ>                                                    |
    | OS-EXT-SRV-ATTR:host                 | <MHV[N].AZ.METACLOUD.NET>                               |
    | OS-EXT-SRV-ATTR:hypervisor_hostname  | <MHV[N].AZ.METACLOUD.NET>                               |
    | OS-EXT-SRV-ATTR:instance_name        | instance-00000033                                       |
    | OS-EXT-STS:power_state               | Running                                                 |
    | OS-EXT-STS:task_state                | None                                                    |
    | OS-EXT-STS:vm_state                  | active                                                  |
    | OS-SRV-USG:launched_at               | 2016-08-03T15:23:24.000000                              |
    | OS-SRV-USG:terminated_at             | None                                                    |
    | accessIPv4                           |                                                         |
    | accessIPv6                           |                                                         |
    | addresses                            | AZ-1902=10.9.2.26                                       |
    | config_drive                         |                                                         |
    | created                              | 2016-08-03T15:23:21Z                                    |
    | flavor                               | m1.medium (3)                                           |
    | hostId                               | b7f85739d1...1                                          |
    | id                                   | bc779ee4-f...a                                          |
    | image                                | Ubuntu-Server-14.04-CloudImage-MC-raw (ac1deb67-e14...) |
    | key_name                             | None                                                    |
    | name                                 | testing                                                 |
    | os-extended-volumes:volumes_attached | []                                                      |
    | progress                             | 0                                                       |
    | project_id                           | bfeb143f18...2                                          |
    | properties                           |                                                         |
    | security_groups                      | [{u'name': u'default'}]                                 |
    | status                               | ACTIVE                                                  |
    | updated                              | 2016-08-03T15:23:24Z                                    |
    | user_id                              | a90bb8eaa2...a                                          |
    +--------------------------------------+---------------------------------------------------------+
    
  3. Show the diagnostics statistics.

    $ nova diagnostics <SERVER_NAME>
    +---------------------------+---------------+
    | Property                  | Value         |
    +---------------------------+---------------+
    | cpu0_time                 | 1025600000000 |
    | cpu1_time                 | 964390000000  |
    | memory                    | 4194304       |
    | memory-actual             | 4194304       |
    | memory-available          | 4048140       |
    | memory-major_fault        | 830           |
    | memory-minor_fault        | 12644244      |
    | memory-rss                | 772092        |
    | memory-swap_in            | 0             |
    | memory-swap_out           | 0             |
    | memory-unused             | 3779252       |
    | tap65dd6eb9-fb_rx         | 147601267     |
    | tap65dd6eb9-fb_rx_drop    | 0             |
    | tap65dd6eb9-fb_rx_errors  | 0             |
    | tap65dd6eb9-fb_rx_packets | 2340499       |
    | tap65dd6eb9-fb_tx         | 418760        |
    | tap65dd6eb9-fb_tx_drop    | 0             |
    | tap65dd6eb9-fb_tx_errors  | 0             |
    | tap65dd6eb9-fb_tx_packets | 3190          |
    | vda_errors                | -1            |
    | vda_read                  | 198181888     |
    | vda_read_req              | 17116         |
    | vda_write                 | 609559552     |
    | vda_write_req             | 32211         |
    +---------------------------+---------------+
    
  4. Show the summary statistics for each project.

    $ openstack usage list
     Usage from 2017-03-22 to 2017-04-20:
    +-----------------+---------+--------------+-----------+---------------+
    | Project         | Servers | RAM MB-Hours | CPU Hours | Disk GB-Hours |
    +-----------------+---------+--------------+-----------+---------------+
    | Interop-proj    |      87 |      5509.12 |      2.69 |          53.8 |
    | Rbtdproj        |       7 |   1874086.82 |    915.08 |      18301.63 |
    | Tenant A        |      11 |   3679664.39 |   2109.23 |      42184.54 |
    +-----------------+---------+--------------+-----------+---------------+