diff --git a/doc/Pacemaker_Explained/en-US/Ch-Alerts.txt b/doc/Pacemaker_Explained/en-US/Ch-Alerts.txt index 79e7aef35f..499b6498d7 100644 --- a/doc/Pacemaker_Explained/en-US/Ch-Alerts.txt +++ b/doc/Pacemaker_Explained/en-US/Ch-Alerts.txt @@ -1,298 +1,319 @@ -= Receiving Alerts for Cluster Events = += Alerts = //// We prefer [[ch-alerts]], but older versions of asciidoc don't deal well with that construct for chapter headings //// -anchor:ch-alerts[Chapter 7, Receiving Alerts for Cluster Events] +anchor:ch-alerts[Chapter 7, Alerts] indexterm:[Resource,Alerts] -A Pacemaker cluster is an event-driven system. In this context, an 'event' -might be a resource failure or a configuration change, among others. +'Alerts' may be configured to take some external action when a cluster event +occurs (node failure, resource starting or stopping, etc.). +== Alert Agents == +As with resource agents, the cluster calls an external program (an +'alert agent') to handle alerts. The cluster passes information about the event +to the agent via environment variables. Agents can do anything +desired with this information (send an e-mail, log to a file, +update a monitoring system, etc.). +.Simple alert configuration +===== +[source,XML] +----- + + + + + +----- +===== -[[s-alerts-configuration]] -== Configuring Alerts via Alert-Agents == +In the example above, the cluster will call +my-script.sh+ for each event. -As with resource-agents an external program (alert-agent) is required to pass alerts generated from cluster events to a recipient (IP address, email address, URI). +Multiple alert agents may be configured; the cluster will call all of them for +each event. -When triggered, the alert-agent is fed with dynamically filled environment -variables describing precisely the cluster event that occurred. By making -smart usage of these variables in your alert-agent code, you can trigger -any action. -It is possible to use multiple alert-agents at the same time. +== Alert Recipients == -Similarly as with resource-agents, +meta-attributes+ can be used to configure how pacemaker is treating the alert-agent (formatting of environment-variables, timeout-handling, ...). +Each alert may be configured with one or more recipients. +The cluster will call the agent separately for each recipient. -If an alert-agent needs additional configuration - again similar as with resource-agents - +instance-attributes+ can be added to be passed to the alert-agents as additional environment variables. +.Alert configuration with recipient +===== +[source,XML] +----- + + + + + + + +----- +===== -For each of the configured alert-agents it is possible to configure multiple recipients. The alert-agents are called separately for each of the recipients configured. +In the above example, the cluster will call +my-script.sh+ for each event, +passing the recipient +some-address+ as an environment variable. -Instance- and meta-attributes can either be configured globally per alert-agent and/or per recipient. +The recipient may be anything the alert agent can recognize -- +an IP address, an e-mail address, a file name, whatever the particular +agent supports. -[NOTE] -===== -When there are multiple alert-agents and/or recipients configured on each cluster event there are multiple processes forked at the same time - for each alert-agent and each recipient one. -Assuming that not all of these processes get scheduled right away this would lead to timestamps, being taken from withing these processes, would differ for a single cluster event. And they would be delayed. +== Alert Meta-Attributes == -Thus pacemaker creates a u-second-resolution timestamp whenever a cluster event occurs and passes that to the alert-agents. +As with resource agents, meta-attributes can be configured for alert agents +to affect how Pacemaker calls them. -Furthermore pacemaker as well passes an every time increased sequence-number whenever an alert-agent is called. The sequence-numbers are valid just withing one cluster-node. An alert created for a cluster event that happened later in time does reliably have a higher sequence number than those for cluster events that had happened prior to this event. -===== +.Meta-Attributes of an Alert -[NOTE] -===== -The interface is realized as backward-compatible evolution of the interfaces previously provided with +ocf:pacemaker:Clustermon+ and *integrated-notifications*. -To preserve script-compatibility the environment-variables passed to the alert-agents are available prepended +CRM_notify+ (compatibility version) as well as +CRM_alert+. And they implement a superset of those previous features. -===== +[width="95%",cols="m,1,2 - - - - - - + + + - + + + + + + + + + + ----- ===== -.Sending Cluster Events as SNMP Traps +In the above example, the +my-script.sh+ will get called twice for each event, +with each call using a 15-second timeout. One call will be passed the recipient ++someuser@example.com+ and a timestamp in the format +%D %H:%M+, while the +other call will be passed the recipient +otheruser@example.com+ and a timestamp +in the format +%c+. + + +== Alert Instance Attributes == + +As with resource agents, agent-specific configuration values may be configured +as instance attributes. These will be passed to the agent as additional +environment variables. The number, names and allowed values of these +instance attributes are completely up to the particular agent. + +.Alert configuration with instance attributes ===== [source,XML] ----- - - - - - - + + + - - - - ------ -Alternatively attributes can be added to the recipient-section as well. -[source,XML] ------ - - - - - - - - - - - + + + + ----- ===== -.Sending Cluster Events as E-Mails + +== Using the Sample Alert Agents == + +Several sample alert agents are provided in the +https://github.com/ClusterLabs/pacemaker/tree/master/extra/alerts[+extra/alerts+] +directory of the pacemaker source tree. If you installed Pacemaker via a +package, these might be available somewhere on your system, such as ++/usr/share/pacemaker+. + +While these sample scripts may be used directly as alert agents, +they are provided mainly as templates to be edited to suit your purposes. +See their source code for the full set of instance attributes they support. + +.Sending cluster events as SNMP traps ===== [source,XML] ----- ----- ===== -[[s-alerts-reference]] -== Alerts - Reference == +.Sending cluster events as e-mails +===== +[source,XML] +----- + + + + + + + + + + +----- +===== -.Environment Variables Passed to the External Agent - Common +== Writing an Alert Agent == -[width="95%",cols="m,2>",options="header",align="center"] + +.Environment variables passed to alert agents + +[width="95%",cols="m,2