Questo contenuto non è disponibile nella lingua selezionata.
8. Alerts
Alert definitions cannot be created or edited using the CLI, but there are some management tasks that can still be performed. For fired alerts themselves, server-side scripts can be used as alert responses (and the alert referenced as an implicit variable) and the fired alert can be viewed and acknowledged by an administrator. Definitions can be enabled or disabled.
8.1. Using Alerts with Scripts Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
One possible response to an alert is for the server to automatically run a stored server script (essentially a stored CLI script file).
That server-side alert script can reference the alert object for the triggered alert. The server defines an implicit alert variable, which pulls in the alert information, ID, definition, and other information for the fired alert.
Because the
alert
method identifies the alert definition, it identifies the resource which triggered the alert. This allows you to create a reusable proxy resource definition in the script that could be applied to any resource which uses that alert script.
For example:
var myResource = ProxyFactory.getResource(alert.alertDefinition.resource.id)
var myResource = ProxyFactory.getResource(alert.alertDefinition.resource.id)
Note
This method is only available to server-side script used with alerts, not to the interactive CLI or external CLI script files.
8.2. Acknowledging Alerts Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
One common administrative action when an alert is fired is for an administrator to review and then acknowledge the alert, which effectively closes it. This script example acknowledges all of the current alerts for all Linux platform resources.
The criteria for the search can be set to be more restrictive so that only certain alerts or only certain resources are included in the action.
The steps in this script:
- Search for fired alerts; in this case, the search is based on the resource type (Linux).
- Retrieve the data for the search results.
- Acknowledge all returned alerts.
Example 26. Acknowledging Alerts for Platform Resources
8.3. Enabling or Disabling Alert Definitions Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
Alert definitions cannot be created or edited through the CLI, but they can be enabled or disabled.
This example script disables all of the definitions returned in the search. In real life, the criteria for the search are crucial to make sure that only the right definitions are disabled, rather than disabling large blocs of definitions.
The steps in this script:
- Search for matching alert definitions based on priority (low, in this case).
- Retrieve the data for the search results.
- Disable all returned alert definitions, based on the IDs in the retrieved search list.
Example 27. Disabling Alerts Based on Priority