HP-UX Event ManagerProgrammer's Guide
from the need to provide the information repeatedly during the post requests. For information
on how to decide what to include in an event template, see “Deciding What to Put in an
Event Template” (page 25).
For information about how the contents of event templates are merged with the contents of a
posted event, see “Merging Data Items from Templates and Posted Events” (page 26).
Templates are stored in files that are held in a central database. For more information about
templates, see “Installing Template Files — Location, Naming, Ownership, and Permission
Requirements” (page 27). You can put any number of event templates in a template file.
Deciding What to Put in an Event Template
Deciding which data items must be supplied by event posters, and which data items must be
supplied by templates is a design-level decision. As a general rule, including constant data items
in the event template is better than hardcoding them into an event by posting programs.
A key benefit of the event template mechanism is that it enables you to centralize the constant
attributes of all events in your application, making it very easy to change them during the
development cycle. This also provides a single place to look for the information after the
application has been deployed.
As a general rule, minimize the amount of event information that you hard code into a posting
application program, and provide as much as information possible into the event template.
Typically, your application must only provide the following information:
• Event name (required — it must have at least three components and be at least as long as
the event name in the matching template)
• Values of any variables
The template must generally include the following entities:
• Event name (required — it must have at least two components)
• Priority
• Format text
• I18N message catalog information (for internationalized events)
• Variables (usually initialized to zero values or empty strings)
Although the posting application is generally expected to supply values for variable data items
when it posts an event, including the variable in the template is helpful because this makes the
template more valuable as a point of documentation. In the template, you must typically set
variable values to 0 (or for string variables, set an empty string). In some special cases, providing
a real default value in a template (which can be overridden by the poster) may be useful — if
this is the case, describe the situation as a comment in the template file.
Example 2-2 is an example of an event template file containing one event.
Example 2-2 Event Template File
# Example event file
priority 200 # Default priority
ref cat:myapp_exp.cat
# Global reference
event
{
name myco.myapp.env.temperature
format "Temperature is $temperature"
var { name temperature type FLOAT value 0,0 }
}
You can include as many variables as you like in an event. However, opaque variables (binary
structures) are not supported in templates.
Designing Event Templates 25