next up previous
Next: PICA inner workings Up: PICA Framework for Integrated Previous: The scheduler

The PIFIA Perl package

By now you should have realized that we like Perl and we have used it throughout PICA. Well, for better integration with the program, the alarms are also written in Perl, of course, and the facilities are a bunch of Perl subs in a package. As you have probably guessed, the package is pifia, and is distributed with PICA (no recursive dependency here, no alarms are used to install a file).

The most important feature of the alarms package is the environment perseval (persistent eval, it's not that we like Arturic legends and we can't write the name of the knight of Galles). It looks like this:

perseval {
   if ($lastnotify - time() > $timebetweennots &&
         some_other_condition()) {
      print "Heck, some other condition, and I haven't notified you since ",
            "$lastnotify\n";
   }

   @down = check_hosts();
   foreach my $host (@down) {
      print "New host down: $host" unless grep { $_ eq $host }
                                               @downhosts;
   }

   $attrs{'something'} = calculate_something();
} preserve '$lastnotify', '@downhosts', '%attrs';

As you've probably noticed here, the perseval environment lets you write code with persistent variables. Those are specified in the preserve clause, after the program. Run the program, check whatever you want, and the variables you specify will have the same value the had the last time you ran the program. Really useful. All of this is implemented with the MLDBM package, so you need it installed in your system for this this to work.


next up previous
Next: PICA inner workings Up: PICA Framework for Integrated Previous: The scheduler
Esteban Manchado Velázquez 2002-12-13