事件通知¶
事件本质上是与云环境相关的虚拟和物理资源的状态显著或有意义的变化。事件用于监控系统,使用率和计费系统,或者是用于辨别模式和做出正确商业决定的其他任何事件驱动工作流系统。在 CloudStack 中的事件可以是虚拟或物理资源的状态变化,用户(操作事件)执行的操作,或基于策略的事件(警告)。
事件日志¶
这里有两种类型的事件记录在&PRODUCT;事件日志。标准事件记录一个事件的成功或失败,并且可以用于鉴别哪些是已经失败的任务或进程。这里也记录长时间运行任务事件。异步任务的制定,启动,完成这些事件都被记录。长时间运行的同步和异步事件日志可用于获取挂起任务更多的状态信息,也可以用来识别任务是被挂起或还未开始。以下各节提供有关这些事件的详细信息。
通知¶
事件通知框架提供一种手段来管理管理服务器组件来发布和订阅 CloudStack 中的事件。事件通知是通过实现事件总线抽象的管理服务器的概念来实现。事件总线的管理服务器,允许 CloudStack 中的组件和扩展插件通过使用高级消息队列协议(AMQP)客户端订阅事件的介绍。在 CloudStack 中,事件总线默认通过一个使用Rabbit MQAMQP 客户端 的插件实现。AMQP 客户端推送发布事件到兼容 AMQP 服务器。因此,所有的 CloudStack 中的事件发布到 AMQP 服务器中交换 。
状态变化,资源状态变化的新事件作为事件通知架构的一部分被引入。每个资源,例如用户VM,卷VM,网卡,网络,公共IP,快照以及模板,使用机器状态和常规事件被关联起来作为状态变化的一部分。这意味着,一个资源状态的变化产生了一个状态变化事件,并且该事件被公布到相应的状态事件总线。所有的 CloudStack 事件(报警,动作事件,使用事件)和 资源状态变化事件的附加条目将被公布到事件总线。
使用案例¶
以下是一些使用场景:
使用率或计费引擎:第三方云使用的解决方案可以实现一个插件,它可以连接到 CloudStack 中订阅 CloudStack 中的事件并产生使用率数据。使用率数据是它们的使用的软件消耗。
AMQP的插件可以存放消息队列中的所有事件,然后一个AMQP消息代理可以提供基于主题的通知订阅者。
AMQP的插件可以存放所有事件在一个消息队列中,然后AMQP打乱的 发布和订阅通知服务可以作为一个可插拔的服务,在CloudStack中该服务可以为事件通知提供丰富的API集,如主题为标题的主题和通知。此外,可插拔服务可以处理多租户,认证,授权issues.age代理,并提供基于主题的订阅通知。
配置¶
作为一个 CloudStack 管理员,执行下列一次性配置启用事件通知框架。在运行时不能修改控件行为。
Create the folder /etc/cloudstack/management/META-INF/cloudstack/core
Inside that folder, open spring-event-bus-context.xml.
按照以下实例顶一个叫做 “ eventNotificationBus ” 的实体:
名字:为实体指定一个名字。
服务器: RabbitMQ AMQP 的名字或IP地址
端口 : RabbitMQ服务器运行端口.
用户名: 用户名关联访问 RabbitMQ 服务器的账号。
密码: 密码关联访问 RabbitMQ 服务器账号的用户名。
交流:其中 CloudStack 中事件发布的 RabbitMQ 的服务器上的交流名称。
下面给出一个实体实例:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"> <bean id="eventNotificationBus" class="org.apache.cloudstack.mom.rabbitmq.RabbitMQEventBus"> <property name="name" value="eventNotificationBus"/> <property name="server" value="127.0.0.1"/> <property name="port" value="5672"/> <property name="username" value="guest"/> <property name="password" value="guest"/> <property name="exchange" value="cloudstack-events"/> </bean> </beans>
The eventNotificationBus bean represents the org.apache.cloudstack.mom.rabbitmq.RabbitMQEventBus class.
If you want to use encrypted values for the username and password, you have to include a bean to pass those as variables from a credentials file.
A sample is given below
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd" > <bean id="eventNotificationBus" class="org.apache.cloudstack.mom.rabbitmq.RabbitMQEventBus"> <property name="name" value="eventNotificationBus"/> <property name="server" value="127.0.0.1"/> <property name="port" value="5672"/> <property name="username" value="${username}"/> <property name="password" value="${password}"/> <property name="exchange" value="cloudstack-events"/> </bean> <bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig"> <property name="algorithm" value="PBEWithMD5AndDES" /> <property name="passwordEnvName" value="APP_ENCRYPTION_PASSWORD" /> </bean> <bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor"> <property name="config" ref="environmentVariablesConfiguration" /> </bean> <bean id="propertyConfigurer" class="org.jasypt.spring3.properties.EncryptablePropertyPlaceholderConfigurer"> <constructor-arg ref="configurationEncryptor" /> <property name="location" value="classpath:/cred.properties" /> </bean> </beans>
Create a new file in the same folder called cred.properties and the specify the values for username and password as jascrypt encrypted strings
Sample, with guest as values for both fields:
username=nh2XrM7jWHMG4VQK18iiBQ== password=nh2XrM7jWHMG4VQK18iiBQ==
重启管理服务器。
标准事件¶
事件日志记录三种类型的标准事件
通知:当一个操作被成功执行产生事件。
警告:以下状况产生该事件。
监控模板下载的同时网络被断开
模板下载被放弃
当存储服务器上的问题会导致卷故障转移到镜像存储服务器。
错误:当操作没有成功执行产生该事件
长事件运行任务事件¶
事件日志记录三种类型的标准事件
通知:当一个操作被成功执行产生事件。
警告:以下状况产生该事件。
监控模板下载的同时网络被断开
模板下载被放弃
当存储服务器上的问题会导致卷故障转移到镜像存储服务器。
错误:当操作没有成功执行产生该事件
事件记录查询¶
可以通过用户接口查询数据库日志。系统收集了以下列表事件:
虚拟机创建,删除,以及持续管理操作
虚拟路由器创建,删除,以及持续管理操作
模板创建和删除
网络/压力 负载规则创建和删除
存储卷创建和和删除
用户登录注销
删除和归档事件警告¶
CloudStack 提供你删除或归档那些再也不使用的现存警告和事件的能力。您可以定期删除或存档的任何那些您不能或不想从数据库来解决的警报或事件,
您可以通过快速查看或详情页面直接删除或归档个别警报或事件。如果你想同时删除多个警报或事件,您可以分别使用相应的快捷菜单。您可以按类别删除某个时期的警报或事件。例如,您可以选择诸如 ** USER.LOGOUT**,** VM.DESTROY**,** VM.AG.UPDATE**,** CONFIGURATION.VALUE.EDI** 等类别,依此类推。您还可以查看事件和警报归档或删除的数量。
为了支持删除或归档报警,增加了以下全局参数:
- alert.purge.delay: The alerts older than specified number of days are purged. Set the value to 0 to never purge alerts automatically.
- alert.purge.interval: The interval in seconds to wait before running the alert purge thread. The default is 86400 seconds (one day).
注解
不能同通过UI 或 API 来归档报警或者事件。它们都存放在数据库中用于升级或其他目的。
步骤¶
使用管理员登录到CloudStack管理界面。
在左侧导航栏中,点击事件。
请执行下列操作之一:
归档事件,点击 归档事件,并指定事件类型和日期。
归档事件,点击 删除事件,并指定事件类型和日期。
点击确定。