Designing and Managing Behavior Models - Alarm Actions - Perl Subroutine - Perl Subroutine Example -
Defining a Perl Subroutine      Send Trap

Perl Subroutine Example

As a simple example, suppose that you want to poll a node for the value of an attribute and to fire different triggers depending on the value. Let's say that you're interested in the value of ifEntry.ifOperStatus and that you want to fire different triggers for the values 1 (up), 2 (down), and 3 (testing). You also want to fire a fourth trigger if the value is some other number.

You could solve this problem by using multiple polls with the poll conditions ifEntry.ifOperStatus == 1, ifEntry.ifOperStatus == 2, and so on. However, this would be very inefficient. A better solution would be to use the poll to retrieve the value of the attribute and to fire a trigger if it is successful. So the poll condition would simple be:


   ifEntry.ifOperStatus present

Then, on the transition associated with the poll's trigger, you could execute a Perl subroutine. This subroutine might look something like this:


   if (ifEntry.ifOperStatus == 1) {
FireTrigger("OperStatusUp");
}
elsif (ifEntry.ifOperStatus == 2) {
FireTrigger("OperStatusDown");
}
elsif (ifEntry.ifOperStatus == 3) {
FireTrigger("OperStatusTest");
}
else {
FireTrigger("OperStatusBad");
}


Defining a Perl Subroutine Send Trap
29 July 2003