We have talked about what an event is and how events are handled but not how an event is defined. In order to post the event, the event has to be defined.
The events template files that are provided with Tru64 UNIX and TruCluster Server have events grouped in a template file by the type of the event; for example, hardware network events are located in the hw.net.evt file, and AdvFS file system events are located in the fs.advfs.evt file.
A template file has the following format:
event { name event_name format format_specifier priority priority cluster_event true | false i18n_catalog i18n_cat i18n_set_id i18n_set i18n_msg_id i18n_msg reference reference_string var { name variable_name type variable_type value variable_value } }
name
Every event must have a name attribute that consists of at least three components. Components are separated by a period (.). For example:
tcrhb.timeEvent.overdue
format
The format attribute is the text of the event. For example:
"TCR Handbook: this book is overdue"
priority
The priority is any value between 0 (zero) and 700. See the EvmEvent(5) reference page for the priority definitions.
cluster_event
The cluster_event attribute is used to define the scope of the event. If cluster_event is "true", then if this event occurs on any member in the cluster, every member in the cluster will see it. If cluster_event is "false", then only the member that generates the event will see the event. As you can see from the previous example, all events in the hw.evt template file default to a cluster_event value of "true".
i18n_catalog, i18n_set_id, i18n_msg_id
If you are using message catalogs, the "i18n" attributes can be used to index into the catalog message for the event text. See the evmtemplate(5) reference page for more information.
reference
This is a text string that is to be used by the event channel's explanation function. The string's format is defined by the event channel.
var
You can also pass variables to your event by defining a "var" block. The variable has three attributes: name, type, and value. The "name" attribute is the name of variable, and the "type" attribute can be any of several different types as defined in the EvmEvent(5)reference page. The type "STRING" is the default. The "value" attribute is the default value that you want the variable to have.
Here is a template for our fictional event that includes a variable:
event { name tcrhb.timeEvent.overDue format "TCR HB: this book is overdue. $dueDate is the due date." priority 400 var {name dueDate type STRING value "Today"} }
Type the event template into a file.
# cd /usr/share/evm/templates/local ; mkdir tcrhb ; cd tcrhb
# cat > tcrhb.evt event { name tcrhb.timeEvent.overDue format "TCR HB: this book is overdue. $dueDate is the due date." priority 400 var {name dueDate type STRING value "Today"} } ^D
Set the owner and permissions.
# chown root tcrhb.evt # chmod 640 tcrhb.evt
Check the template file for syntax errors.
# evmreload -n
Tell EVM about the new template.
# evmreload
Post the new event.
# echo "event { name tcrhb.timeEvent.overDue }" | evmpost
Check to see if the event was posted.
# evmget -A -f "[name tcrhb]" TCR Handbook: this book is overdue. Today is the due date.
Post the event again. This time, pass a value to the "dueDate" variable.
# print "event > { name tcrhb.timeEvent.overDue > var {name dueDate value \"$(date)\"} }" | evmpost
Retrieve the events. This time you should see two events since this is the second time we have posted an event.
# evmget -A -f "[name tcrhb]" TCR Handbook: this book is overdue. Today is the due date. TCR Handbook: this book is overdue. Mon Mar 26 05:34:29 EST 2001 is the due date.
Finally, you can define a default attribute value for all events in a template file by placing the attribute entry outside of the event definition. An attribute within an event definition will override the "global" attribute value. Here is an excerpt from the hw.evt template file that illustrates the point:
#============ Hardware event defaults ============================ cluster_event true priority 200 ref cat:evmexp.cat:800 #============ Hardware event templates =========================== ... event { name @SYS_VP@.hw.deregistered priority 400 format "A hardware component has been de-registered (HWID=$_hwid)" var {name _hwid type UINT64 value 0} } ... event { name @SYS_VP@.hw.scan_completed format "A hardware scan has just completed" } ...
Notice that the cluster_event, priority, and ref attributes are not defined within an event template. This means that any event templates below these entries will have these attribute defaults unless specifically overridden within the event template. So, the @SYS_VP@.hw.scan_completed event template would have the "default" priority of 200, but the @SYS_VP@.hw.deregistered event template would override the default priorityand assign a priority of 400.
For additional information regarding event templates, see the evmtemplate(5) and EvmEvent(5) reference pages.