Wednesday, March 12, 2008

TEC: Ensuring User Predicates Load

One of the best features of the Tivoli Enterprise Console is the ability to create custom Prolog predicates that are callable from within event processing rules. The Prolog source can be loaded into the TEC environment using either the consult/* built-in or the user_predicates file in TEC_TEMPLATES. The tricky part is verifying that your custom Prolog actually compiles and loads when TEC start, as the only indication you get is things break...

Here is a mechanism to test and alert if a Prolog source file in TEC_TEMPLATES does not load.

Refer to the Rule Builder's Guide for instructions of implementing your custom Prolog from the TEC_TEMPLATES directory. This article will assume that you already have created your source files and have a valid TEC_TEMPLATES/user_predicates file.

The compile and load process does funny things to your Prolog source. When a rule base is loaded, the files are copied to $DBDIR/tec/rb_dir and the compile process seems to translate the Prolog source file into so we will have to take this into account when we check to see if the file is loaded.

In BIM Prolog you can check if a Prolog file has been loaded using the current_file/1 built-in. If the argument to current_file/1 is a free variable then the predicate will backtrack and provide a list of every file that is loaded in the environment. If you use a ground variable then the predicate will only succeed if the specified file is loaded.

So to check the files loaded from TEC_TEMPLATES we will have to give the full path and tack on the to end of the file name. Here is a simple reception action to perform the checks and generate an event when a file is not loaded.

_templates_dir = '$DBDIR/tec/rb_dir/TEC_TEMPLATES',
'User predicate file TEC_TEMPLATES/%s was not loaded.',
generate_event('TEC_Error',[ hostname=_hostname,


The same basic method can be used to check any consulted Prolog file, but you will have explicitly check each file you tried to consult.

No comments: