Go to main content
Oracle® ZFS Storage Appliance 管理ガイド、Release OS8.7.0

印刷ビューの終了

更新: 2017 年 3 月
 
 

アラートアクションでのワークフローの使用

ワークフローは、オプションでアラートとして実行できます。ワークフローをアラートアクションとして使用できるようにするには、その alert アクションが true に設定されている必要があります。

アラートアクションとして実行される場合、ワークフローは、そのワークフローを作成したユーザーの ID を引き継ぎます。このため、アラートアクションとして使用できるワークフローはすべて、setidtrue に設定されている必要があります。アラートアクションには、次のメンバーを持つ 1 つのオブジェクトパラメータがあります。

表 146  アラートの実行コンテキストの必須メンバー
必須メンバー
タイプ
説明
class
文字列
アラートのクラス。
code
文字列
アラートのコード。
items
オブジェクト
アラートを記述したオブジェクト。
timestamp
日付
アラートの時間。

parameters オブジェクトの items メンバーには、次のメンバーがあります。

表 147  items メンバーの必須メンバー
必須メンバー
タイプ
説明
url
文字列
アラートを記述した Web ページの URL
action
文字列
アラートに対応してユーザーが実行するべきアクション。
impact
文字列
アラートの原因となったイベントの影響。
description
文字列
アラートを記述した、人間が読める形式の文字列。
severity
文字列
アラートの原因となったイベントの重要度。

アラートアクションとして実行されているワークフローは、audit 関数を使用して監査ログエントリを生成できます。関連するすべてのデバッグ情報を audit 関数を経由して監査ログに生成することをお勧めします。たとえば、クラスタ化された状態にある場合はフェイルオーバーを実行するが、リブートの失敗をすべて監査するワークフローを次に示します。

使用例 27  リブートの失敗を監査するワークフロー

たとえば、クラスタ化された状態にある場合はフェイルオーバーを実行するが、リブートの失敗をすべて監査するワークフローを次に示します。

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');
       }
};