Oracle® ZFS Storage Appliance 管理指南,发行版 2013.1.5.0

退出打印视图

更新时间: 2016 年 2 月
 
 

针对警报操作使用工作流

可选择性地将工作流作为警报执行。要使工作流符合作为警报操作的资格,其 alert 操作必须设置为 true

当作为警报操作执行时,工作流以创建工作流的用户身份运行。出于此原因,任何有资格作为警报操作的工作流必须将 setid 设置为 true。警报操作具有一个对象参数,该参数具有以下成员:

表 116  警报执行上下文的必要成员
必要成员
类型
说明
class
字符串
警报的类别。
code
字符串
警报的代码。
items
对象
说明警报的对象。
timestamp
日期
警报的时间。

parameters 对象的 items 成员具有以下成员:

表 117  项目成员的必要成员
必要成员
类型
说明
url
字符串
说明警报的网页 URL
action
字符串
用户响应警报应执行的操作。
impact
字符串
引发警报的事件的影响。
description
字符串
说明警报的用户可读的字符串。
severity
字符串
引发警报的事件的严重性。

作为警报操作执行的工作流可以使用 audit 函数生成审计日志条目。建议通过 audit 函数将所有相关的调试信息生成到审计日志中。例如,下面是如果处于群集状态则执行故障转移的工作流-但是它审计所有无法重新引导故障:

示例 20  审计无法重新引导故障的工作流

例如,下面是如果处于群集状态则执行故障转移的工作流-但是它审计所有无法重新引导故障:

var workflow = {
       name: 'Failover',
       description: 'Fail the node over to its clustered peer',
       alert: true,
       setid: true,
       execute: function (params) {
               /*
                * To failover, we first confirm that clustering is configured
                * and that we are in the clustered state.  We then reboot,
                * which will force our peer to takeover.  Note that we're
                * being very conservative by only rebooting if in the
                * AKCS_CLUSTERED state:  there are other states in which it
                * may well be valid to failback (e.g., we are in AKCS_OWNER,
                * and our peer is AKCS_STRIPPED), but those states may also
                * indicate aberrent operation, and we therefore refuse to
                * failback.  (Even in an active/passive clustered config, a
                * FAILBACK should always be performed to transition the
                * cluster peers from OWNER/STRIPPED to CLUSTERED/CLUSTERED.)
                */
               var uuid = params.uuid;
               var clustered = 'AKCS_CLUSTERED';

               audit('attempting failover in response to alert ' + uuid);

               try {
                       run('configuration cluster');
               } catch (err) {
                       audit('could not get clustered state; aborting');
                       return;
               }

               if ((state = get('state')) != clustered) {
                       audit('state is ' + state + '; aborting');
                       return;
               }

               if ((state = get('peer_state')) != clustered) {
                       audit('peer state is ' + state + '; aborting');
                       return;
               }

               run('cd /');
               run('confirm maintenance system reboot');
       }
};