云计算

ceilometer 磁盘使用率的问题

2021-06-15  本文已影响0人  cloudFans

[root@compute001 ceilometer-compute]# vi polling.yaml

    - disk.device.capacity
    - disk.device.allocation
    - disk.device.usage

E:\yealink-code\ceilometer\setup.cfg

cpu_total = ceilometer.compute.pollsters.instance_stats:CPUTotalPollster
memory.max = ceilometer.compute.pollsters.instance_stats:MemoryMaxPollster

vcpu mem 相关代码

metadata['vcpus'] = instance.flavor['vcpus']
metadata['memory_mb'] = instance.flavor['ram']
metadata['disk_gb'] = instance.flavor['disk']
metadata['ephemeral_gb'] = instance.flavor['ephemeral']
metadata['root_gb'] = (int(metadata['disk_gb']) -
                       int(metadata['ephemeral_gb']))

return sample.add_reserved_user_metadata(conf, instance.metadata,
                                         metadata)

{'name': 'disk.device.read.bytes', 'type': 'cumulative', 'unit': 'B', 'volume': 83216384,
'user_id': '185f782e50331bdee5890a3a5a09617246846b9e9bc56c1ac44d0686ba92666d',
'project_id': '29f1625d1c31449384683542990573c8',
'resource_id': '69253826-f8f6-4941-b8c7-d51f4b8830fa-vde',
'timestamp': None,
'resource_metadata':
{'display_name': 'eu-ev-base-s6-c1m2-4xlarge-asg-htk-s7r-mbi-server-2j3',
'name': 'instance-0004b340',
'instance_id': '69253826-f8f6-4941-b8c7-d51f4b8830fa',
'instance_type': 's6-c1m2.4xlarge',
'host': 'f6efcc824eaea38ce6a4d634d69c94a578d7e759685928ff20a0d025',
'instance_host': 'compute001',
'flavor': {'id': 'f85b2c2b-cabc-481f-abbf-f135181f7f52', 'name': 's6-c1m2.4xlarge', 'vcpus': 16, 'ram': 32768, 'disk': 50, 'ephemeral': 0, 'swap': 0}, 'status': 'active', 'state': 'running', 'task_state': '', 'image': None, 'image_ref': None, 'image_ref_url': None, 'architecture': 'x86_64', 'os_type': 'hvm', 'vcpus': 16, 'memory_mb': 32768, 'disk_gb': 50, 'ephemeral_gb': 0, 'root_gb': 50, 'disk_name': 'vde'},
'source': 'openstack', 'id': '19e87c08-c99a-11eb-a968-3868dd420470', 'monotonic_time': 16483827.498306384}

上报信息 显示租户 资源id 虚拟机名 便利于后续根据租户进行过滤

yum install libguestfs-dev libguestfs libguestfs-tools

(nova-libvirt)[root@compute007 /]# virsh domblkinfo 9794ddbd-7d90-4c0a-a108-ba81edac4da2 --all --human
Target Capacity Allocation Physical


vda 50.000 GiB 50.000 GiB 50.000 GiB
vdb 80.000 GiB 72.250 GiB 80.000 GiB
vdc 40.000 GiB 30.269 GiB 40.000 GiB
vdd 5.000 GiB 2.245 GiB 5.000 GiB

[root@zbb-test-numa ~]# virt-df -h
Filesystem Size Used Available Use%
n31-2048M-pin-0-3:/dev/sda1 7.8G 1.2G 6.6G 16%

pip install https://download.libguestfs.org/python/guestfs-1.40.2.tar.gz

python3-libguestfs-1.40.2-27.module_el8.4.0+783+f8734d30.x86_64
https://github.com/libguestfs/libguestfs/blob/master/python/examples/inspect_vm.py

  1. 基于命令行 virsh domblkinfo

(nova-libvirt)[root@compute007 /]# virt-df -h
Filesystem Size Used Available Use%
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue
libguestfs: error: cannot get the value of the secret with UUID ‘ed7ca988-84e7-4219-9f4e-2e303215f1e5’: operation forbidden: read only access prevents virSecretGetValue
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue
libguestfs: error: cannot get the value of the secret with UUID ‘ed7ca988-84e7-4219-9f4e-2e303215f1e5’: operation forbidden: read only access prevents virSecretGetValue
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue
libguestfs: error: cannot get the value of the secret with UUID ‘ed7ca988-84e7-4219-9f4e-2e303215f1e5’: operation forbidden: read only access prevents virSecretGetValue
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue
libguestfs: error: cannot get the value of the secret with UUID ‘ed7ca988-84e7-4219-9f4e-2e303215f1e5’: operation forbidden: read only access prevents virSecretGetValue
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue
libguestfs: error: cannot get the value of the secret with UUID ‘ed7ca988-84e7-4219-9f4e-2e303215f1e5’: operation forbidden: read only access prevents virSecretGetValue
libguestfs: error: cannot get the value of the secret with UUID ‘ed7ca988-84e7-4219-9f4e-2e303215f1e5’: operation forbidden: read only access prevents virSecretGetValue
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue
libguestfs: error: cannot get the value of the secret with UUID ‘ed7ca988-84e7-4219-9f4e-2e303215f1e5’: operation forbidden: read only access prevents virSecretGetValue
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue
libguestfs: error: cannot get the value of the secret with UUID ‘ed7ca988-84e7-4219-9f4e-2e303215f1e5’: operation forbidden: read only access prevents virSecretGetValue
libvirt: Secrets Driver error : operation forbidden: read only access prevents virSecretGetValue

目前会被用户权限挡住

(nova-libvirt)[root@compute007 /]# virsh secret-list
UUID Usage


0c066223-5e88-445c-b57e-a5ab9ec22b73 ceph client.nova secret
ed7ca988-84e7-4219-9f4e-2e303215f1e5 ceph client.cinder secret

(nova-libvirt)[root@compute007 /]#

而且该命令无法指定ceph secret作为参数,所以云硬盘的使用率,关键还是基于ceph来做一下,基于ceilometer 以及 libvirt 很难有一个靠谱的方案。

(nova-libvirt)[root@compute007 /]# cat /etc/libvirt/qemu.conf
stdio_handler = "file"

user = "nova"
group = "nova"

max_files = 32768
max_processes = 131072

  1. 基于代码

https://github.com/libguestfs/libguestfs/blob/master/python/examples/inspect_vm.py

代码明显没有命令行好用,需要指定磁盘,这很麻烦,命令行可以一次性list所有dom,但是接口镜像不行

g = guestfs.GuestFS(python_return_dict=True)

Attach the disk image read-only to libguestfs.

g.add_drive_opts(disk, readonly=1)

Run the libguestfs back-end.

g.launch()

上一篇 下一篇

猜你喜欢

热点阅读