Using Workflows for Alert Actions
A workflow can be executed as an alert action. A workflow that is executed as an alert action is the selected Workflow for the Execute workflow Alert action (BUI), or is the value of the workflow
property of the execute_workflow
handler (CLI), as described in Adding Alert Actions.
To enable a workflow to be executed as an alert action, the
workflow
global variable must specify an alert:
true
member.
By default, workflows execute as the user that is executing the workflow. However, a
workflow that is executed as an alert action executes by default as the user that
created the workflow. To be able to be executed as an alert action, the
workflow
global variable of the workflow must specify a
setid: true
member.
Alert actions have a single object parameter that has the following members.
Table 9-8 Required Members for Alert Execution Context
Required Member | Type | Description |
---|---|---|
|
String |
The class of the alert |
|
String |
The code of the alert |
|
Object |
An object describing the alert |
|
Date |
Time of alert |
The items
member of the parameters object has the following members:
Table 9-9 Required Members for the items
Member
Required Member | Type | Description |
---|---|---|
|
String |
The URL of the web page describing the alert |
|
String |
The action that should be taken by the user in response to the alert |
|
String |
The impact of the event that precipitated the alert |
|
String |
A human-readable string describing the alert |
|
String |
The severity of the event that precipitated the alert |
Example 9-11 Workflow Auditing Failure to Reboot
Workflows that execute as alert actions can use the audit
function to generate audit log entries. For example, debugging information should be written to the audit log.
See the multiple uses of the audit
function in the
following example. This workflow:
-
Is executed in response to alert
params.uuid
, specifying this workflow to execute. -
Reboots the system only if both controllers are in the clustered state.
-
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) { 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'); } };