Designing and Managing Behavior Models
-
Using Trap Masks - Writing a Trigger Function -
If a mask cannot completely describe the type of trap it is looking for by specifying the contents of the trap's Generic trap, Enterprise, and Specific trap fields, it must contain a trigger function. This function, which you write using Perl, can include additional conditions that the trap must meet, and it can fire different triggers as appropriate.
Most trigger functions are very similar in structure. They follow this pattern:
if (condition1) {
FireTrigger(arguments);
}
elsif (condition2) {
FireTrigger(arguments);
}
else {
FireTrigger(arguments);
}
The conditions, which can be arbitrarily complex, generally test the contents of a trap's variable bindings. However, they can test other information as well; for example, a condition can determine whether a trap came from a particular node. The FireTrigger() function fires a trigger, whose name, subobject, and node you can control.
To assist you in writing trigger functions, NerveCenter provides:
For further information about these predefined functions and variables and the pop-up help menu, see the following sections:
Also, see the section Examples of Trigger Functions. This section presents several sample trigger functions that show a number of the functions and variables being used in context.
NerveCenter provides a number of functions (actually Perl subroutines) that facilitate the writing of trigger functions. The list below indicates what types of functions are available and where you can find detailed information about each function:
For reference information about these functions, see the section Variable-Binding Functions.
For reference information about these functions, see the section String-Matching Functions on page 159.
For reference information about this function, see the section DefineTrigger() Function on page 155.
For reference information about this function, see the section FireTrigger() Function on page 156.
For reference information about this function, see the section AssignPropertyGroup() Function on page 158.
For reference information about this function, see the section in( ) Function on page 159.
Before looking at the variable-binding functions, let's make sure that we're using the same terminology.
When a trap arrives, NerveCenter looks at the trap's variable bindings and, for each variable binding, it sees an object and a value.
In this case, the object is the OID encoding of the object type (sysDescr) plus an instance, and the value is a string that describes the system.
When NerveCenter sees this variable binding, it stores the following information. The portion of the OID that corresponds to the system group is stored as the binding's base object, and the instance (0) is stored as the binding's instance. When concatenated, the base object and the instance form what NerveCenter calls a subobject.
Base Objects, Instances, and Subobjects
The variable sysDescr is stored as the binding's attribute.
Finally, the value "Windows Workstation" is stored as the binding's value.
The variable-binding functions give you access to a binding's subobject, attribute, and value. There's also a function that returns the number of variable bindings in a trap or trigger.
Each of the variable-binding functions is explained below:
Description: Returns the attribute from the variable binding with an index of index. The first variable binding has an index of 0.
Description: Returns the number of variable bindings in the trap's variable-binding list.
Description: Returns the subobject from the variable binding with an index of index. The first variable binding has an index of 0.
Description: Returns the value from the variable binding with an index of index. The first variable binding has an index of 0.
NerveCenter defines several variables for use in trap mask trigger functions. For the most part, these variables contains the values of the fields in a trap's Protocol Data Unit (PDU), with the exception of the variable bindings.
The complete list of variables that you can use in a trap mask trigger function is shown in tVariables Used in Trigger Functions:
Variables Used in Trigger Functions
Variable | Description |
---|---|
The time, in hundredths of a second, between the last initialization of the network entity and the generation of the trap |
Defining a Trap Mask | Examples of Trigger Functions |
29 July 2003 |