簡介html
osprofiler是專門針對OpenStack的性能調優工具,採集到的信息能夠存入ceilometer、redis、mongodb、elasticsearch等後端,默認存儲在ceilometer中。python
安裝git
仍是以devstack方式先安裝個OpenStack出來,上個local.conf配置文件(性能信息存入ceilometer)redis
[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
安裝過程,就不詳細敘述了!sql
注意:devstack安裝osprofiler的時候,會以pip install osprofiler的方式安裝(可能有坑),須要pip uninstall osprofiler,mongodb
而後切換到osprofiler源碼目錄,執行python setup.py build && python setup.py install.後端
使用api
# 使用上面定義好的OSPROFILER_HMAC_KEYS中的任意一個 [stack@yao-devstack2 devstack]$ nova --profile charlie \ boot --p_w_picpath 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 | | p_w_picpath | 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報告bash
[stack@yao-devstack2 devstack]$ osprofiler trace show --html 7c157a83-8608-45c2-9989-68da9a18906e \ --out /tmp/a.html
來看看報告格式python2.7
參考連接
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