简介
osprofiler是专门针对OpenStack的性能调优工具,采集到的信息可以存入ceilometer、redis、mongodb、elasticsearch等后端,默认存储在ceilometer中。
安装
还是以devstack方式先安装个OpenStack出来,上个local.conf配置文件(性能信息存入ceilometer)
[stack@yao-devstack2 devstack]$ cat local.conf [[local|localrc]] # use trystack git mirror GIT_BASE=http://git.trystack.cn NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git SPICE_REPO= # enable panko, panko provides event storage for ceilometer now. enable_plugin panko http://git.trystack.cn/openstack/panko enable_plugin ceilometer http://git.trystack.cn/openstack/ceilometer enable_plugin osprofiler http://git.trystack.org/openstack/osprofiler master #CEILOMETER_BACKEND=mongodb RECLONE=no # add profiler topic CEILOMETER_NOTIFICATION_TOPICS=notifications,profiler # define osprofiler hmac keys OSPROFILER_HMAC_KEYS=swordfish,foxtrot,charlie enable_service ceilometer-api PANKO_BACKEND=mongodb [[post-config|$NOVA_CONF]] [profiler] enabled = True trace_sqlalchemy = True
安装过程,就不详细叙述了!
注意:devstack安装osprofiler的时候,会以pip install osprofiler的方式安装(可能有坑),需要pip uninstall osprofiler,
然后切换到osprofiler源码目录,执行python setup.py build && python setup.py install.
使用
# 使用上面定义好的OSPROFILER_HMAC_KEYS中的任意一个 [stack@yao-devstack2 devstack]$ nova --profile charlie boot --image 8e02a6be-511a-4904-a400-87f8d86a5862 --flavor 1 --nic net-id=cbfdd288-2357-4161-8180-f7d6bd001420 test1 /usr/lib/python2.7/site-packages/novaclient/client.py:278: UserWarning: The ‘tenant_id‘ argument is deprecated in Ocata and its use may result in errors in future releases. As ‘project_id‘ is provided, the ‘tenant_id‘ argument will be ignored. warnings.warn(msg) +--------------------------------------+-----------------------------------------------------------------+ | Property | Value | +--------------------------------------+-----------------------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | | | OS-EXT-SRV-ATTR:host | - | | OS-EXT-SRV-ATTR:hostname | test1 | | OS-EXT-SRV-ATTR:hypervisor_hostname | - | | OS-EXT-SRV-ATTR:instance_name | | | OS-EXT-SRV-ATTR:kernel_id | | | OS-EXT-SRV-ATTR:launch_index | 0 | | OS-EXT-SRV-ATTR:ramdisk_id | | | OS-EXT-SRV-ATTR:reservation_id | r-on04hs1u | | OS-EXT-SRV-ATTR:root_device_name | - | | OS-EXT-SRV-ATTR:user_data | - | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | scheduling | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | - | | OS-SRV-USG:terminated_at | - | | accessIPv4 | | | accessIPv6 | | | adminPass | vzJTN6apxGu7 | | config_drive | | | created | 2017-03-14T02:08:48Z | | description | - | | flavor | m1.tiny (1) | | hostId | | | host_status | | | id | a399a3f0-3ee5-4dbe-bc71-61cde64f3107 | | image | cirros-0.3.5-x86_64-disk (8e02a6be-511a-4904-a400-87f8d86a5862) | | key_name | - | | locked | False | | metadata | {} | | name | test1 | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | security_groups | default | | status | BUILD | | tags | [] | | tenant_id | fb39574612b748e9b3dcd4597b8cf3c4 | | updated | 2017-03-14T0 | user_id | c376ccfaa36842889becad4491488941 | +--------------------------------------+-----------------------------------------------------------------+ To display trace use the command: osprofiler trace show --html 7c157a83-8608-45c2-9989-68da9a18906e
生成html报告
[stack@yao-devstack2 devstack]$ osprofiler trace show --html 7c157a83-8608-45c2-9989-68da9a18906e --out /tmp/a.html
来看看报告格式
参考链接
https://docs.openstack.org/developer/osprofiler/api.html#five-ways-to-add-a-new-trace-point
http://niusmallnan.com/_build/html/_templates/openstack/osprofiler.html
本文出自 “the-way-to-cloud” 博客,请务必保留此出处http://iceyao.blog.51cto.com/9426658/1906273
原文地址:http://iceyao.blog.51cto.com/9426658/1906273