Designing and Managing Behavior Models - Using Trap Masks - Writing a Trigger Function - Examples of Trigger Functions -
Writing a Trigger Function      Documenting a Trap Mask

Examples of Trigger Functions

This section presents several trigger functions and explains what the functions do.

Example 1


   if ($NodeName ne "troublemaker") {
FireTrigger("gotIt");
}

If the node that sent the trap is any node except troublemaker, issue a trigger named gotIt. This example would be useful if you had a device sending inappropriate traps. The trigger function would allow you to pay attention to a trap only when it came from other, more dependable, devices.

Example 2


   if (system.sysContact eq "Tom Jones") {
FireTrigger("jonesJob");
} else {
FireTrigger("otherAdmin");
}

If the first variable binding containing the sysContact attribute has the value "Tom Jones," a jonesJob trigger is issued. Otherwise, an otherAdmin trigger is issued.

Example 3


   if (snmp.snmpInBadCommunityNames > 25) {
FireTrigger("tooManyIntrusions", VbObject(2));
}

If the snmpInBadCommunityNames attribute is found in one of the variable bindings, its value is checked. If there were at least 26 attempts to communicate with the trap's node without the proper community string before the trap was issued, a tooManyIntrusions trigger is issued. The subobject assigned to the trigger is the subobject associated with the third variable binding.

This would be an effective way to ignore authorization traps until they became significant.

Example 4


   if (ContainsString(VbValue(2)), "crucial message") {
FireTrigger("trig");
}

If the third variable binding, assumed here to be defined as a DisplayString, contains the string "crucial message," the trigger trig is generated. This type of trigger function is useful when text messages are sent to NerveCenter via traps.

Example 5


   if ((VbNum() == 5) && (.8 * VbValue(3) < VbValue(4))) {
FireTrigger("diskSpaceLow", VbObject(1));
} elsif ((VbNum() == 4) && (VbValue(3) > 400000000)) {
FireTrigger("diskSpaceLow", VbObject(1));
}

This example assumes that there is an enterprise-specific trap that contains information about disk space use. An older version of the vendor's agent sent a trap with four variable bindings, the last variable binding containing the amount of disk space used (VbValue(3) > 400000000)). A newer version of the agent sends traps with five variable bindings: the last binding contains disk space used, and the next to last contains the disk space capacity. If a trap arrives from a newer agent, you want to fire a trigger only if available disk space is less than 20 percent. This trigger function not only enables you to ignore noncritical situations, but handles all releases of your vendor's device.

Example 6


   if (VbValue(0) == 1) {
FireTrigger("thisProblem", VbObject(2), VbValue(1));
} elsif (VbValue(0) == 2) {
FireTrigger("thatProblem", VbObject(2), VbValue(1));
} elsif (VbValue(0) == 3) {
FireTrigger("otherProblem", VbObject(2), VbValue(1));
} else {
FireTrigger("huhProblem", VbObject(2), VbValue(1));
}

This example is illustrates how to deal with a class of traps sent by some vendors in which the trap's source and specific number are constant. These vendor's agents insert a problem identifier and the source of the problem into the trap's variable bindings. This example assumes that the problem identifier is in the first variable binding, the source node is in the second, and any other associated data follows in successive positions.


Writing a Trigger Function Documenting a Trap Mask
29 July 2003