Ceilometer alarm 初学习
2014-01-14 17:47
225 查看
ceilometer H版本开始支持alarm的功能。
Alarm的定义:
Essentiallyan alarm
is just a set of rules defining a monitor, plus a currentstate, with edge-triggered actions associated with target states.These alarms follow a tri-state model of ok, alarm,and insufficient
data.
可见alarm是一组规则的集合,定义了对哪个meter进行监控,alarm状态以及某状态下的触发动作。alarm有3个状态:ok,alarm,
insufficient data.
一个alarm的结构大致如下:
{
"id": "123456789",
"name": "SwiftObjectAlarm",
"description": "A alarm is raise when 2 aggregates of 240 seconds are greater than 2.0 swift objects",
"timestamp": "2013-04-08T05:17:13.698331", # timestamp of last update
"counter_name": "storage.objects",
"user_id": "a3b70c53b94648438b442b485606e7cf", # owner of the alarm
"project_id": "bfe523aebf2f4e5e9a997a9452927811", # project owner of the alarm
"aggregate_period": 240.0,
"evaluation_period": 2,
"statistic": "average",
"metadatas": {"project_id": "c96c887c216949acbdfbd8b494863567"}, # the project_id used to match a sample or not "comparison_operator": "gt",
"threshold": 2.0,
"state" : 1,
"state_timestamp": "2013-04-08T05:17:13.698331",
"alarm_actions": [ "http://site:8000/%(state_text)s" ],
"ok_actions": [ "http://site:8000/%(state_text)s" ],
"insufficient_data_actions": [ "http://site:8000/%(state_text)s" ]
}
Alarm与
meter的关系:
Alarm的处理流程图:
代码分析
rpc.py:
定义了两种类型的Notifier:
RPCAlarmNotifier
RPCAlarmPartitionCoordination
service.py:
首先定义了AlarmService基础Service类,提供一些公共的方法:
_load_evaluators:使用stevedore以extension的方式加载evaluator的实现(在Python包ceilometer.alarm.evaluator下面).
_evaluate_assigned_alarms:先获取alarm集合,对每一个alarm,调用_evaluate_alarm方法。
_evaluate_alarm:根据alarm的type,将alarm分配给对应的evaluator进行处理。
_assigned_alarms:获取alarm集合的抽象方法,具体实现交给子类来完成。
AlarmService的两个子类:
SingletonAlarmService:作为一个OpenstackService,周期性(默认为60s)的调用_evaluate_assigned_alarms方法来对定义的alarms进行计算(evaluate).
PartitionedAlarmService:是一个OpenstackRPCService,依赖PartitionCoordinator类,除了完成和SingletonAlarmService一样的的功能---周期调用_evaluate_assigned_alarms外,还周期运行PartitionCoordinator的report_presence(1/4周期)和check_mastership方法(1/2周期)。同时作为RPCService,它还会处理消息队列中topic为“alarm_partition_coordination”的消息。(对应于RPCAlarmPartitionCoordination)
service.py中还定义了
AlarmNotifierService:也是一个OpenstackRPC
Service,依赖ceilometer.alarm.notifier包中的notifierplugin实现。接收消息队列中topic为“alarm_notifier”的消息(由evaluator发出的)并调用notify_alarm方法,notify_alarm方法调用_handle_action方法,最终通过notifier.notify来执行alarm的action.
UML 类图:
疑问:
PartitionCoordinator类是做什么用的,
何谓partition coordination protocol?
Alarm的定义:
Essentiallyan alarm
is just a set of rules defining a monitor, plus a currentstate, with edge-triggered actions associated with target states.These alarms follow a tri-state model of ok, alarm,and insufficient
data.
可见alarm是一组规则的集合,定义了对哪个meter进行监控,alarm状态以及某状态下的触发动作。alarm有3个状态:ok,alarm,
insufficient data.
一个alarm的结构大致如下:
{
"id": "123456789",
"name": "SwiftObjectAlarm",
"description": "A alarm is raise when 2 aggregates of 240 seconds are greater than 2.0 swift objects",
"timestamp": "2013-04-08T05:17:13.698331", # timestamp of last update
"counter_name": "storage.objects",
"user_id": "a3b70c53b94648438b442b485606e7cf", # owner of the alarm
"project_id": "bfe523aebf2f4e5e9a997a9452927811", # project owner of the alarm
"aggregate_period": 240.0,
"evaluation_period": 2,
"statistic": "average",
"metadatas": {"project_id": "c96c887c216949acbdfbd8b494863567"}, # the project_id used to match a sample or not "comparison_operator": "gt",
"threshold": 2.0,
"state" : 1,
"state_timestamp": "2013-04-08T05:17:13.698331",
"alarm_actions": [ "http://site:8000/%(state_text)s" ],
"ok_actions": [ "http://site:8000/%(state_text)s" ],
"insufficient_data_actions": [ "http://site:8000/%(state_text)s" ]
}
Alarm与
meter的关系:
Alarm的处理流程图:
代码分析
rpc.py:
定义了两种类型的Notifier:
RPCAlarmNotifier
RPCAlarmPartitionCoordination
service.py:
首先定义了AlarmService基础Service类,提供一些公共的方法:
_load_evaluators:使用stevedore以extension的方式加载evaluator的实现(在Python包ceilometer.alarm.evaluator下面).
_evaluate_assigned_alarms:先获取alarm集合,对每一个alarm,调用_evaluate_alarm方法。
_evaluate_alarm:根据alarm的type,将alarm分配给对应的evaluator进行处理。
_assigned_alarms:获取alarm集合的抽象方法,具体实现交给子类来完成。
AlarmService的两个子类:
SingletonAlarmService:作为一个OpenstackService,周期性(默认为60s)的调用_evaluate_assigned_alarms方法来对定义的alarms进行计算(evaluate).
PartitionedAlarmService:是一个OpenstackRPCService,依赖PartitionCoordinator类,除了完成和SingletonAlarmService一样的的功能---周期调用_evaluate_assigned_alarms外,还周期运行PartitionCoordinator的report_presence(1/4周期)和check_mastership方法(1/2周期)。同时作为RPCService,它还会处理消息队列中topic为“alarm_partition_coordination”的消息。(对应于RPCAlarmPartitionCoordination)
service.py中还定义了
AlarmNotifierService:也是一个OpenstackRPC
Service,依赖ceilometer.alarm.notifier包中的notifierplugin实现。接收消息队列中topic为“alarm_notifier”的消息(由evaluator发出的)并调用notify_alarm方法,notify_alarm方法调用_handle_action方法,最终通过notifier.notify来执行alarm的action.
UML 类图:
疑问:
PartitionCoordinator类是做什么用的,
何谓partition coordination protocol?
相关文章推荐
- [ASP学习] —— 1、简单的留言薄
- 几个学习网站
- Duwamish学习
- Effective STL 学习(1)
- 学习使用资源文件[7] - 字符串资源
- 学习技术的几个境界
- PL/SQL 学习笔记(一)----- pl/sql 基本查询与排序
- Linux学习要点
- JMS学习心得(一)
- SEO学习3
- Ruby学习笔记一——语言基础
- JSP学习笔记
- Freemarker标签学习
- H.264学习指南
- PHP学习笔记之二
- 如何学习Android
- jquery学习(一)
- FLASH学习资料整理
- OK6410 Linux开发环境搭建--编译以及ubuntu的使用方法学习笔记
- 新浪微博iOS版SDK框架学习笔记