Search code examples
openstack

Get memory, cpu and disk usage for each tenant in Openstack


I am looking for the CPU, Memory and Disk consumption for each Tenant in Openstack,and their relationship by users, instances, flavors in use. Horizon only shows utilization of memory, cpu of a global way. Is it possible to get it with Openstack commands?

My openstack is based on Rocky.

Any ideas will be really appreciated


Solution

  • The only thing I know is

    openstack limits show --absolute --project <Project_ID/Tenant_ID>

    see also https://docs.openstack.org/python-openstackclient/pike/cli/command-objects/limits.html

    In the output you have information like for example totalCoresUsed, which represents the number of cores, which are used by the selected project.

    Example:

    root@openstack-controller:~# openstack limits show --absolute --project 416f937f505f4ff6b623c48a61228a86
    +--------------------------+-------+
    | Name                     | Value |
    +--------------------------+-------+
    | maxTotalInstances        |    10 |
    | maxTotalCores            |    20 |
    | maxTotalRAMSize          | 51200 |
    | maxSecurityGroups        |    10 |
    | maxTotalFloatingIps      |    10 |
    | maxServerMeta            |   128 |
    | maxImageMeta             |   128 |
    | maxPersonality           |     5 |
    | maxPersonalitySize       | 10240 |
    | maxSecurityGroupRules    |    20 |
    | maxTotalKeypairs         |   100 |
    | maxServerGroups          |    10 |
    | maxServerGroupMembers    |    10 |
    | totalRAMUsed             |  2560 |
    | totalCoresUsed           |     7 |
    | totalInstancesUsed       |     7 |
    | totalFloatingIpsUsed     |     0 |
    | totalSecurityGroupsUsed  |     1 |
    | totalServerGroupsUsed    |     0 |
    | maxTotalVolumes          |    10 |
    | maxTotalSnapshots        |    10 |
    | maxTotalVolumeGigabytes  |  1000 |
    | maxTotalBackups          |    10 |
    | maxTotalBackupGigabytes  |  1000 |
    | totalVolumesUsed         |     5 |
    | totalGigabytesUsed       |     7 |
    | totalSnapshotsUsed       |     0 |
    | totalBackupsUsed         |     0 |
    | totalBackupGigabytesUsed |     0 |
    +--------------------------+-------+
    

    The quotas and so the limitations are bind to projects and not to users, so I don't know if it is possible to get a relationshit by users. The only idea I would have, would a simple bash-script, which iterates over all instances and volumes of a project and collect the information of each ressource by the user, who created it.

    Update 30.7.2020:

    Found a better solution now, which also allows to get the resource usage per user of a project. It comes with the new placement-component with the stein-release of openstack (tested in train-release of openstack).

    Installation of the openstack-client extension: pip install osc-placement

    Ressource-usage of a project:

    openstack resource usage show --os-placement-api-version 1.9 <PROJECT_ID>

    Ressource-usage of a specific user within a project:

    openstack resource usage show --os-placement-api-version 1.9 --user-id <USER_ID> <PROJECT_ID>

    Example:

    openstack resource usage show --os-placement-api-version 1.9 --user-id 98378bd3cdd94218bf7b6ef4ec80e74a  7733616a513444c2a106243db318b0dd
    +----------------+-------+
    | resource_class | usage |
    +----------------+-------+
    | VCPU           |     3 |
    | MEMORY_MB      |   768 |
    | DISK_GB        |     9 |
    +----------------+-------+