Go to main content

Oracle® ZFS Storage Appliance Administration Guide, Release OS8.7.x

Exit Print View

Updated: September 2017
 
 

Using Workflows for Alert Actions

Workflows may be optionally executed as an alert. To allow a workflow to be eligible as an alert action, its alert action must be set to true.

When executed as alert actions, workflows assume the identity of the user that created them. For this reason, any workflow that is to be eligible as an alert action must set setid to true. Alert actions have a single object parameter that has the following members:

Table 147  Required Members for Alert Execution Context
Required Member
Type
Description
class
String
The class of the alert.
code
String
The code of the alert.
items
Object
An object describing the alert.
timestamp
Date
Time of alert.

The items member of the parameters object has the following members:

Table 148  Required Members for the Items Member
Required Member
Type
Description
url
String
The URL of the web page describing the alert
action
String
The action that should be taken by the user in response to the alert.
impact
String
The impact of the event that precipitated the alert.
description
String
A human-readable string describing the alert.
severity
String
The severity of the event that precipitated the alert.

Workflows executing as alert actions may use the audit function to generate audit log entries. It is recommended that any relevant debugging information be generated to the audit log via the audit function. For example, here is a workflow that executes failover if in the clustered state -- but audits any failure to reboot:

Example 27  Workflow Auditing Failure to Reboot

For example, here is a workflow that executes failover if in the clustered state -- but audits any failure to reboot:

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