Using the Custom Alert Functions

The createalert function creates a custom alert, and the postalert function posts the alert. The createalert function can be called from a script or from a workflow. The postalert function must be called from a workflow. See Creating and Posting Custom Alerts from Within a Workflow.

  1. The following function call creates a minimalist custom alert.
    createalert([{'handler': 'syslog', 'args': {}}], {description: 'Writes to syslog'});
  2. The following script specifies additional parameters and captures the return value.

    The return value is required to post the alert. Although the postalert call is shown in this script, postalert needs to be called from within a workflow in response to an event that occurs in the workflow.

    script
    ("." to run)> var actions = [{
    ("." to run)>     handler: 'email',
    ("." to run)>     args: {
    ("." to run)>         address: 'admin@example.com',
    ("." to run)>         subject: 'Custom Alert Response'
    ("." to run)>     }
    ("." to run)> }];
    ("." to run)> var params = {
    ("." to run)>     severity: 'Minor',
    ("." to run)>     description: 'Custom alert description',
    ("." to run)>     response: 'What the alert action does',
    ("." to run)>     impact: 'What happened to the appliance',
    ("." to run)>     recommended_action: 'What the administrator should do'
    ("." to run)> };
    ("." to run)> var cuuid = createalert(actions, params);
    ("." to run)> print(cuuid);
    ("." to run)> var puuid = postalert(cuuid);
    ("." to run)> .
    54c24732-b9c5-4b57-9aee-aeaf195afdae