Designing and Managing Behavior Models - Using Polls - Writing a Poll Condition -
Defining a Poll      The Basic Procedure for Creating a Poll Condition

Writing a Poll Condition

Every poll must include a poll condition. This poll condition, which you write using Perl, specifies which MIB variables the poll should read, what conditions the values of those variables must meet, and what triggers will be fired each time a value makes a condition true. For example, the following poll condition detects whether a node's desired and current operational status are both up and, if they are, fires the trigger ifUp:


   if (ifEntry.ifAdminStatus == up and ifEntry.ifOperStatus == up) {
FireTrigger("ifUp");
}

Note that both the MIB variables referred to in this condition are children of the same base object (ifEntry). In a single poll condition, you can only refer to one base object. If the condition that you want to detect requires that you inquire about variables associated with multiple base objects, you must design multiple polls.

Another important point about poll conditions is that if a poll causes a trigger to be fired, that trigger's variable bindings will include a name-value pair for each MIB variable referred to in the poll condition and read by the poll. If such a trigger causes a logging action, the value of each variable used in the poll condition is written to the log.

Most poll conditions are very similar in structure. They follow this pattern:


   if (condition1) {
FireTrigger(arguments);
}
elsif (condition2) {
FireTrigger(arguments);
}
else {
FireTrigger(arguments);
}

The conditions can be arbitrarily complex, and the FireTrigger() function fires a trigger, whose name, subobject, and node you can control.

Because a poll condition is written in Perl, you can use any data types, operators, and functions that Perl understands in this condition. Also, you can make use of a number of functions and one variable defined by NerveCenter. The functions and variables available to you are summarized in a pop-up menu for Perl accessible via a right mouse click from the poll condition editing area. (See the following section, Using the Pop-Up Menu for Perl, for more information.)

For all the details about writing a poll condition, see the following sections:


Defining a Poll The Basic Procedure for Creating a Poll Condition
29 July 2003