...
Code Block | ||
---|---|---|
| ||
'default' => { 'subject'=> [ "event.date", ' ',"node.name", ' ', "event.event" ], 'body' => [ "Event Context:\n", "link.eventcontext", "\n\n", "Node Properties:\n","node.*","\n\n", "Event Properties:\n","event.*","\n","\n", ], }, 'veryshort' => { 'subject' => [ "node.name", ' ', "event.event" ], 'body' => [ "The event \"","event.event", "\" for host \"", "node.name", "\" occurred at ", "event.date", ".\nAll event details can be found here: ", "link.eventcontext", "\n", "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 An email template consists of two named lists of items to include, in one for the mail subject and one for the body.
- The template lists define what order you want them the items to be shown.
- The template controls the email message body; the subject is fixed.
- Entries like
node.XYZ
,event.ABC
andlink.EFG
(ormacro.HIJ
) are treated specially, but only if they are isolated separate items.
For example, the text entry "The lazy fox likes node.group" is not special because herenode.group
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).
As these are all perl strings, the "@", "$" and "%" characters are special: within double-quoted strings you'll need to prefix those with a backslash. No such problems arise when you use single-quoted strings, but then no backslash escapes whatsoever are recognized in single-quoted strings. - 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
orevent.XYZ
are replaced by the node or event propertyXYZ
.
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 common node properties are documented here, and the event properties are listed on this page. - From opEvents 2.2 onwards, special entries of the form
macro.XYZ
are replaced by the value of the macro namedXYZ
(which are defined in theopCommon.nmis
configuration file, in the sectionmacro
). - 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.
Both of these hyperlink generators rely on the settingopevents_url_base
inopCommon.nmis
to set an appropriate schema and hostname for the hyperlink. if this setting is missing you'll seehttp://localhost/
in the created hyperlinks. - Entries of the form
node.*
are translated into a list of all "standard summary" node properties, which are defined inopCommon.nmis
, keyopevents_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. - Both special forms
node.*
andevent.*
are disabled in the subject template, because that must contain just a single line of text. You also must not create multiple lines of text in the subject template (using "\n").
Associating an email contact with a template
...