Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

opEvents releases after 1.1.0 include a facility to define your own templates for email notifications (ie. emails as part of an event action or because of an escalation).

The setup is very simple and requires basically just two steps:

  1. deciding on what information to present and in what order, and
  2. associating a contact with a particular template.

Defining custom email templates

The configuration file install/EventEmails.nmis contains the definitions of all email templates. As shipped it includes one special template named default, which is chosen for all email contacts without a template association, and one example for a very concise report. You can of course modify these existing templates or define your own. Here are these two example templates:

'default' => [
 	"Event Context:\n", "link.eventcontext", "\n\n",
 	"Node Properties:\n","node.*","\n\n",
 	"Event Properties:\n","event.*","\n","\n",
'veryshort' => [
	"The event \"","event.event", "\" for host \"", "", 
	"\" occurred at ", "",
	".\nAll event details can be found here: ", "link.eventcontext", 
	"All node details can be found here: ", "link.nodecontext", "\n\n",

The syntactic rules for templates are simple but  flexible:

  • A template is simply a named list of items to include, in order you want them to be shown.
  • The template controls the email message body; the subject is fixed.
  • Entries like node.XYZevent.ABC and link.EFG are treated specially, but only if they are isolated separate items.
    For example, the text entry "The lazy fox likes"  is not special because here is part of a longer bit of text.
  • All non-special plain text items are included as-is, ie. for generating static header or footer text.
  • You can write your texts either single- our double-quoted; within double-quoted strings all the standard backslash escapes work - e.g. "\t" for a tab character)
  • Newlines are NOT created automatically. You have to include "\n" for that (within your double-quoted strings, or as separate item) whereever you want a line break.
  • The line breaks in the actual template definition are not relevant.
  • All special entries, of the form node.XYZ or event.XYZ are replaced by the node or event property XYZ.
    If the property is structured, with sub-elements (e.g. event.script), then these are shown on separate lines and indented with a tab character.
  • The entry link.eventcontext is replaced by a hyperlink to the event context page.
  • The entry link.nodecontext creates a hyperlink to the node context page.
  • Entries of the form node.* are translated into a list of all "standard summary" node properties, which are defined in opCommon.nmis, key opevents_gui_event_node_summary_list.
    For this summary, the property name is shown first, followed by a colon and a space, the property value, and a newline; repeated for each property. There is a trailing newline.
  • The form event.* works similarly, but for event properties and is not restricted to a default set. It also creates a trailing newline.
  • No labels