ceilometer的幾個概念
ceilometer 主要有下面幾個概念:
- meter 是ceilometer定義的監(jiān)控項,諸如內(nèi)存占用琼蚯,網(wǎng)絡IO违施,磁盤IO等等
- sample 是每個采集時間點上meter對應的值
- statistics 一般是統(tǒng)計學上某個周期內(nèi)僵蛛,meter對應的值(平均值之類)
- resource 是被監(jiān)控的資源對象尚蝌,這個可以是一臺虛擬機,一臺物理機或者一塊云硬盤
- alarm 是ceilometer的告警機制充尉,你可以通過閾值或者組合條件告警飘言,并設置告警時觸發(fā)的action
Meter
資源使用的某個計量項,它的屬性包括:名稱(name)驼侠、單位 (unit)姿鸿、類型 (cumulative:累計值,delta:變化值倒源、gauge:離散或者波動值)以及對應的資源屬性等苛预。
Sample
某時刻某個 resource 的某個 meter 的值。Sample 的收集有區(qū)間概念笋熬,即收集數(shù)據(jù)的時間間隔热某。它的屬性出了meter屬性外,還有 timestampe(采樣時間)和 Volume (采樣值)。
Statistics
一個時間段(Period)內(nèi)的 samples 聚合值昔馋,包括計數(shù)(Count)芜繁、最大(Max)、最腥藜(Min)、平均 (Avg)蔬捷、求和(Sum)等垄提。例如:
這里的Period表示當前該查詢的區(qū)間,使用 -p 參數(shù)指定
需要注意的是周拐,你可以使用 ”-q“ 指定統(tǒng)計的目標范圍铡俐。當不指定的時候,表示對當前租戶(tenant)內(nèi)的所有虛機的 sample 做統(tǒng)計妥粟。比如指定 resource_id 來只統(tǒng)計某一個虛機:
ceilometer statistics -m cpu_util -p 60 -q resource_id=d7ce68d4-3d58-404c-85a6-f9c19fe9d96c审丘。
ceilometer組成部分
ceilometer組成部分:
1.控制節(jié)點。
Central Agent: 調(diào)用OpenStack其它組件api采集指標
Notification Agent:接收其它組件主動上報的通知消息
Collector:基于AMQP接收消息勾给,并記錄到DataStore
API:運行在管理節(jié)點滩报,提供接口訪問Data Store
2.計算機點。
Compute Agent:采集本節(jié)點性能指標
ceilometer監(jiān)控項
Ceilometer原生支持的監(jiān)控指標有很多播急,考慮到消息服務器和數(shù)據(jù)庫的壓力脓钾,根據(jù)項目需要,只保留需要的指標桩警,其它默認裁剪可训。同時,擴展了部分指標捶枢。
1.虛擬機
- cpu:cpu使用時間
- cpu_util:cpu使用率
- vcpus:使用vcpu數(shù)量
- disk.total.size:磁盤總大小
- memory:內(nèi)存總大小
- memory.usage:內(nèi)存使用大小
- disk.read.bytes:磁盤讀字節(jié)數(shù)
- disk.read.bytes.rate:磁盤讀速率
- disk.write.bytes:磁盤寫字節(jié)數(shù)
- disk.write.bytes.rate:磁盤寫速率
- network.incoming.bytes:網(wǎng)絡incoming字節(jié)數(shù)
- network.incoming.bytes:網(wǎng)絡incoming字節(jié)數(shù)
- network.incoming.bytes.rate:網(wǎng)絡incoming速率
- network.outgoing.bytes:網(wǎng)絡outgoing字節(jié)數(shù)
- network.outgoing.bytes.rate:網(wǎng)絡outgoing速率
2.物理機
- compute.node.cpu.percent:cpu利用率
- compute.node.disk.total:磁盤總大小
- compute.node.disk.used:磁盤使用大小
- compute.node.memory.total:內(nèi)存總大小
- compute.node.memory.used:內(nèi)存使用大小
- compute.node.disk.read.bytes:磁盤讀字節(jié)數(shù)
- compute.node.disk.read.bytes.rate:磁盤讀速率
- compute.node.disk.write.bytes:磁盤寫字節(jié)數(shù)
- compute.node.disk.write.bytes.rate:磁盤寫速率
- compute.node.network.incoming.bytes:網(wǎng)絡incoming字節(jié)數(shù)
- compute.node.network.incoming.bytes.rate:網(wǎng)絡incoming速率
- compute.node.network.outgoing.bytes:網(wǎng)絡outgoing字節(jié)數(shù)
- compute.node.network.outgoing.bytes.rate:網(wǎng)絡outgoing速率
- compute.node.network.bandwidth:物理網(wǎng)卡帶寬
ceilometer收集數(shù)據(jù)的方式
OpenStack原始數(shù)據(jù)的收集方式有兩種:
一種是通過ceilometer polling agent主動輪詢方式握截,調(diào)用相應插件獲取性能數(shù)據(jù);
另一種是各openstack核心組件主動向消息隊列上報自身的性能數(shù)據(jù)烂叔。這兩種收集方式都將原始數(shù)據(jù)發(fā)送到消息隊列谨胞。
ceilometer notification agent監(jiān)聽該消息隊列,并將這些原始數(shù)據(jù)按照一定規(guī)則轉(zhuǎn)換成sample和event长已,再發(fā)布到配置的目的端畜眨。可配的發(fā)布方式包括direct术瓮、notifier康聂、udp、kafka和file胞四。
ceilometer collector是可選服務恬汁,它從notification消息隊列中消費sample和event消息,然后將數(shù)據(jù)dispatch到配置的目的端:database辜伟、file氓侧、http脊另、gnocchi,該目的端可以同時配置多項约巷。Ceilometer的邏輯框架如下圖所示:
ceilometer監(jiān)控項
nova
如果想統(tǒng)計虛擬機的一些信息偎痛,需要做以下更改:
配置項 | 默認值 | 配置項所屬group | 配置文件 | 原因 |
---|---|---|---|---|
instance_usage_audit=True | false | [DEFAULT] | nova.conf | nova默認不會周期性通知所有已知實例的情況,所以如果需要周期獲得這些審計信息需要打開它 |
instance_usage_audit_period=hour | month | [DEFAULT] | nova.conf | 上面開啟了周期性通知的信息,這里就是周期性通知的時間間隔 |
notify_on_state_change=vm_and_task_state | None | [DEFAULT] | nova.conf | 虛擬主機的狀態(tài)發(fā)生變化的時候独郎,nova也會往消息隊列里面發(fā)送消息踩麦,但是需要配置這個配置項 |
notification_driver=messagingv2 | [] | [DEFAULT] | nova.conf | nova發(fā)送notifications信息的驅(qū)動 |
因為對CPU的一些特定資源的監(jiān)控需要在nova里面打開相應的支持,所以需要配置nova的配置文件氓癌,設置compute_monitors添加一個ComputeDriverCPUMonitor谓谦,如下:
# cat /etc/nova/nova.conf
[DEFAULT]
...
compute_monitors = ["ComputeDriverCPUMonitor","cpu.virt_driver","numa_mem_bw.virt_driver"]
...
# 重啟nova-compute服務
# /usr/bin/python /usr/bin/nova-compute
cinder
如果想要獲取一些存儲的信息,需要做一下更改:
配置項 | 默認值 | 配置項所屬group | 配置文件 | 原因 |
---|---|---|---|---|
driver = messagingv2 | [] | [oslo_messaging_notifications] | cinder.conf | cinder發(fā)送notifications信息的驅(qū)動 |
control_exchange = cinder | [DEFAULT] | cinder.conf | cinder的messaging的topic |
ceph
根據(jù)官方的說明,我們需要進行如下的配置:
...
[client.radosgw.gateway]
rgw enable usage log = true
...
對ceilometer的配置:
配置針對radosgw的access_key和secret_key
[rgw_admin_credentials]
#
# From ceilometer
#
# Access key for Radosgw Admin. (string value)
access_key = <None> # 填入你對應的key
# Secret key for Radosgw Admin. (string value)
secret_key = <None> # 填入你對應的key
Neutron
Havana 版本中添加了收集 Neutron Bandwidth samples的功能贪婉。與 Ceilometer 其他采集方式不同的是反粥,bandwidth 的采集是通過 neutron-meter-agent 收集,然后 push 到 oslo-messaging疲迂,ceilometer-agent-notification通過監(jiān)聽消息隊列來收取bandwidth信息才顿。
其實現(xiàn)是在 L3 router 層次來收集數(shù)據(jù)尤蒿,因此需要操作員配置 IP 范圍以及設置標簽(label)娜膘。比如优质,我們加兩個標簽,一個表示內(nèi)部網(wǎng)絡流量巩螃,另一個表示外部網(wǎng)絡流量演怎。每個標簽會計量一定IP范圍內(nèi)的流量避乏。然后,每個標簽的帶寬的測量數(shù)據(jù)會被發(fā)到 MQ拍皮,然后被 Ceilometer 收集到歹叮。
注意:需要先安裝openstack-neutron-metering-agent
yum install -y openstack-neutron-metering-agent
neutron.conf中還需要做一下更改:
[DEFAULT]
service_plugins = metering
重啟網(wǎng)絡服務:
systemctl restart neutron-server
修改/etc/neutron/metering_agent.ini:
[DEFAULT]
# Show debugging output in log (sets DEBUG log level output)
debug = True
driver = neutron.services.metering.drivers.iptables.iptables_driver.IptablesMeteringDriver
# Interval between two metering measures
measure_interval = 30
# Interval between two metering reports
report_interval = 300
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
use_namespaces = True
重啟網(wǎng)絡服務:
systemctl start neutron-metadata-agent
關于neutron配置更為詳細信息,參考網(wǎng)站
ceilometer 常用cli命令
獲取所有的meters
ceilometer meter-list
查詢某種監(jiān)控資源
ceilometer sample-list -m cpu
查詢某個監(jiān)控資源
ceilometer meter-list --query user=xxxx
查詢某種監(jiān)控資源并且限定條件
ceilometer sample-list --meter cpu -q 'resource_id=921903ea-ccda-4eda-b86e-7d44f3aa71c2;timestamp<2015-1
查詢某種資源的統(tǒng)計信息
ceilometer sample-list -m cache.miss
ceilometer statistics --meter cpu_util
查詢現(xiàn)在所有的alarm
ceilometer alarm-list
創(chuàng)建一個alarm
ceilometer alarm-threshold-create --name cache --description 'instance running hot' --meter-name cache --threshold 60.0 --comparison-operator gt --statistic avg --period 600 --evaluation-periods 3 --alarm-action 'log://' --query resource_id=INSTANCE_ID
更新某個alarm的閾值
ceilometer alarm-update --threshold 75 -a ALARM_ID
查詢某個alarm的歷史更改
ceilometer alarm-history -a ALARM_ID
將某個alarm置為無效
ceilometer alarm-update --enabled False -a ALARM_ID
刪除一個alarm
ceilometer alarm-delete -a ALARM_ID
得到某個alarm的狀態(tài)
ceilometer alarm-state-get ALARM_ID
置某個alarm的狀態(tài)
ceilometer alarm-state-set --state ok(alarm) –a ALARM-ID
查看單個alarm的詳細信息
ceilometer alarm-show ALARM-ID
查看單個alarm的狀態(tài)
ceilometer alarm-state-get -a alarm-id
ceilometer快速安裝
puppet-openstack-integration項目可以快速部署openstack all-in-one環(huán)境咆耿,github鏈接:puppet-openstack-integration
部署請參考文章: openstack-all-in-one30分鐘快速搭建
ceilometer.conf配置
下面是用puppet-openstack-integration 跑出來的 all-in-one環(huán)境ceilometer配置如下:
[DEFAULT]
polling_namespaces=central,compute,ipmi
meter_dispatchers=gnocchi
event_dispatchers=gnocchi
http_timeout=600
debug=True
verbose=True
log_dir=/var/log/ceilometer
rpc_backend=rabbit
notification_topics=notifications
[api]
port=8777
host=0.0.0.0
[central]
[collector]
udp_address=0.0.0.0
udp_port=4952
workers=1
batch_size=100
[compute]
[coordination]
[cors]
[cors.subdomain]
[database]
metering_time_to_live=86400
event_time_to_live=86400
connection=mysql+pymysql://ceilometer:ceilometer@127.0.0.1/ceilometer?charset=utf8
metering_connection = mongodb://ceilometer:ceilometer@127.0.0.1:27017/ceilometer
[dispatcher_file]
[dispatcher_gnocchi]
filter_project = services
filter_service_activity = False
resources_definition_file = gnocchi_resources.yaml
[event]
[exchange_control]
[hardware]
[ipmi]
[keystone_authtoken]
auth_uri=http://127.0.0.1:5000/
admin_tenant_name=services
admin_user=ceilometer
admin_password=a_big_secret
identity_uri=http://127.0.0.1:35357/
[matchmaker_redis]
[meter]
[notification]
ack_on_event_error=True
store_events=False
workers=2
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
rabbit_host=127.0.0.1
rabbit_port=5672
rabbit_hosts=127.0.0.1:5672
rabbit_use_ssl=False
rabbit_userid=ceilometer
rabbit_password=an_even_bigger_secret
rabbit_virtual_host=/
rabbit_ha_queues=False
heartbeat_timeout_threshold=0
heartbeat_rate=2
[oslo_policy]
[polling]
[publisher]
metering_secret=secrete
[publisher_notifier]
[rgw_admin_credentials]
[service_credentials]
auth_type=password
auth_url=http://127.0.0.1:5000/
project_name=services
project_domain_name=Default
username=ceilometer
user_domain_name=Default
password=a_big_secret
[service_types]
[storage]
[vmware]
[xenapi]