Openstack node resource statistics

Source: Internet
Author: User

Today, I tracked a statistics of openstack resources and recorded

1. node resource statistics are in the compute_notes table

2. Use the update_available_resource function to read the total resources and available resources in the system/proc/meminfo and calculate the resources that have been used (these values have little to do with the instance and are completely system values)

3. The value of the Key Attribute free_ram_mb free_disk_gb is added and subtracted along with the creation and deletion of the instance.

Update_available_resource call db. compute_node_update

Call _ adjust_compute_node_values_for_utilization

Def _ adjust_compute_node_values_for_utilization (context, values, session): service_ref = service_get (context, values ['service _ id'], session = session) host = service_ref ['host'] ram_mb = values ['memory _ mb'] disk_gb = values ['local _ gb'] values. update (_ get_host_utilization (context, host, ram_mb, disk_gb ): "compute the current utilization of a given host. "instances = instance_get_all_by_host (context, host) VMS = Len (instances) free_ram_mb = ram_mb-flags. reserved_host_memory_mb free_disk_gb = disk_gb-(flags. reserved_host_disk_mb * 1024) Work = 0 for instance in instances: free_ram_mb-= instance. memory_mb free_disk_gb-= instance. root_gb free_disk_gb-= instance. ephemeral_gb if instance. vm_state in [vm_states.building, workshop]: Work + = 1 return dict (free_ram_mb = free_ram_mb, free_disk_gb = free_disk_gb, current_workload = work, running_vms = VMS)

It is implemented through nodify in Capacity_notifier, which is updated every time an instance is operated.

For example, deleting an instance:

    if ended and event == 'delete':        vms = -1        payload = message.get('payload', {})        free_ram_mb = payload.get('memory_mb', 0)        free_disk_gb = payload.get('disk_gb', 0)    LOG.debug("EventType=%(event_type)s -> host %(host)s: "              "ram %(free_ram_mb)d, disk %(free_disk_gb)d, "              "work %(work)d, vms%(vms)d" % locals())    db.api.compute_node_utilization_update(context.get_admin_context(), host,        free_ram_mb_delta=free_ram_mb, free_disk_gb_delta=free_disk_gb,        work_delta=work, vm_delta=vms)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.