Ceilometr: 10、 Ceilometer-Alarm常用命令行

来源:互联网 发布:克拉丽丝claris知乎 编辑:程序博客网 时间:2024/05/16 09:55

Ceilometer-Alarm常用命令行

参考:

http://blog.csdn.net/violet_echo_0908/article/details/52243199

http://blog.csdn.net/hackerain/article/details/38172941



1 查询某个资源的计量项

ceilometerstatistics -q resource_id=<instance_id> -m cpu_util

ceilometerstatistics -q resource_id=640a2be3-632b-4c2b-98f3-75b7f5877d4d -mcpu_util


ceilometeralarm-list



2 创建一个alarm

ceilometeralarm-threshold-create--namecache--description'instancerunning hot'--meter-namecache--threshold60.0--comparison-operatorgt--statisticavg--period600--evaluation-periods3--alarm-action'log://'--queryresource_id=INSTANCE_ID

alarm-threshold-create Create a new alarm based on computed

statistics.

ceilometeralarm-threshold-create --name cpu --description 'instance runninghot' --meter-name cpu_util --threshold 4 --comparison-operator gt--statistic avg --period 60 --evaluation-periods 3 --alarm-action'log://' --query resource_id=640a2be3-632b-4c2b-98f3-75b7f5877d4d


解释:

alarm-threshold-create:

name: 报警名称

meter-name: 监控项民参观横

threshold: 阈值

comparison-operator: 比较操作符号,gt, lt

statistic:统计方式,包括 平均值,

period:间隔时间

evaluation_periods:时间段内数据个数,?

alarm-action:报警动作,?

queryresource_id:查询资源id

repeat_actions :如果报警动作之前触发过了,是否重复触发



3得到报警状态:

计量报警状态获得 报警id

ceilometeralarm-state-getALARM_ID

ceilometeralarm-state-get876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4



4查看单个报警详细信息

计量报警显示 报警id

ceilometeralarm-showALARM-ID

ceilometeralarm-show876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4


5查看单个alarm的状态

计量报警状态获得 报警项 报警id

ceilometeralarm-state-get -a alarm-id

ceilometeralarm-state-get -a 876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4


6更新某个alarm的阈值

计量报警更新 阈值 报警项 报警id

ceilometeralarm-update --threshold 3-a 876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4


7查询某个alarm梗概历史

计量报警历史 报警项 报警id

ceilometeralarm-history -a 876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4


8将某个alarm设置为无效

计量报警更新 开启 无效 报警id

ceilometeralarm-update --enabled False -a 876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4


ceilometeralarm-threshold-create --name cpu --description 'instance runninghot' --meter-name cpu_util --threshold 4 --comparison-operator gt--statistic avg --period 60 --evaluation-periods 3 --alarm-action'log://' --query resource_id=640a2be3-632b-4c2b-98f3-75b7f5877d4d




ceilometeralarm-update --repeat-actions True -a876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4





9设置某个alarm的状态

计量报警状态设置 状态 报警id

ceilometeralarm-state-set --state ok -a 876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4

ceilometeralarm-state-set --state alarm -a 876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4


10删除一个alarm

计量项报警删除 报警id

ceilometeralarm-delete -a 876ef1a6-b1ba-4b61-8ebb-303bc77ee8a4



创建一个alarm,详细的参数见下表:

参数

类型

解释

name

str

nameproject唯一的

description

str

描述

enabled

bool

alarm的一个开关,可以停止/启动该alarm,默认是True

ok_actions

list

alarm状态变为ok状态时,采取的动作,默认是[]

alarm_actions

list

alarm状态变为alarm状态时,采取的动作,默认是[]

insufficient_data_actions

list

alarm状态变为insufficientdata状态时,采取的动作,默认是[]

repeat_actions

bool

alarm被触发时,是否重复执行对应的动作,默认是False

type

str

alarm类型,目前有thresholdcombination两种,必填

threshold_rule

AlarmThresholdRule

alarm类型为threshold时,制定的threshold规则

combination_rule

AlarmCombinationRule

alarm类型为combination时,制定的combination规则

time_constraints

list(AlarmTimeConstraint)

约束该alarm在哪些时间段执行,默认是[]

state

str

alarm的状态,默认是insufficientdata

user_id

str

user id,默认是contextuser id

project_id

str

project id,默认是context project id

timestamp

datetime

alarm的定义最后一次被更新的时间

state_timestamp

datetime

alarm的状态最后一次更改的时间


这里主要说下面几个参数:

  • name:nameproject唯一的,在创建alarm的时候会检查

  • enabled:这个功能比较人性化,可以暂停该alarm,是微创新之一

  • xxx_actions:定义了在该alarm状态由其他的状态变为xxx状态时,执行的动作

  • repeat_actions:这个参数指定了是否要重复执行action,比如第一次检查alarm已经超过阈值,执行了相应的action了,当下一次检查时如果该alarm还是超过阈值,那么这个参数决定了是否要重复执行相应的action,这也是微创新之一

  • threshold_rule:typethreshold时,定义的alarm被触发的规则,详细参数见下面AlarmThresholdRule对象属性

  • combination_rule:typecombination时,定义的alarm被触发的规则,详细参数见下面AlarmCombinationRule对象属性

  • time_constraints:这也是一个很人性化的参数,可以指定该alarm被检查的时间的一个列表,比如说我只想让这个alarm在每天晚上的21点到23点被检查,以及每天中午的11点到13点被检查,其它时间不检查该alarm,这个参数就可以做这个限制,不过该参数设置稍微复杂一点,详细参数见下面AlarmTimeConstraint对象属性,默认是[],即不设限制,随着alarm进程的intervaltime进行检查。

  • state:alarm总共有3个状态:OK,INSUFICIENT DATA, ALARM,这三个状态分别对应到上面的xxx_actions



0 0