nb.mod(7) NodeBrain Administrator Guide
Version 0.9.03 - December 2014
nb.mod(7)

NAME | SYNOPSIS | DESCRIPTION | FILES | RULES | ENVIRONMENT | DIAGNOSTICS | HISTORY | BUGS | AUTHOR | DOCUMENTATION | SEE ALSO


NAME

  nb.mod - NodeBrain Modules (plug-ins)

SYNOPSIS

  #include <nb/nb.h>

See the NodeBrain Library manual for a description of C API functions.

DESCRIPTION

  NodeBrain modules are dynamic load libraries used as plug-ins to extend the capabilities of the NodeBrain Rule Engine, nb(1). Modules may by used to provide "cell functions" for use in formulas. The API is called to bind a C function to a cell function that may then be referenced within formulas in NodeBrain rules. A cell function call that binds to the C sqrt function looks like this.

    `math.sqrt(a)

Modules may also be used to implement one or more node skills. For each skill, the module must implement one or more skill methods (functions) within a defined set. Once declared, a skill may be associated with any number of nodes. A node is an object that has the defined skill, but also (often) the ability to accumulate a set of knowledge independent of other nodes with the same skill.

You will not find enough information here to learn how to write a node module. Here we only provide enough information, hopefully, to demystify NodeBrain modules for those installing or using an existing module. The NodeBrain Library manual describes the API.

See http://nodebrain.org for more information.

FILES

 

/usr/include/nb/nb.h    NodeBrain API header file.
/usr/lib64/nb-series/nb_module.suffix    NodeBrain modules may be located anywhere, provided you direct nb to them using the NB_MODULE_PATH environment variable or a path in a module declaration command. If no path is specified and a module is not found using the native search path, NodeBrain checks in libdir/nb/x.x as show above, where libdir and suffix are determined by the platform.
nb_module.so    [Solaris and Linux]
nb_module.sl    [HP-UX]
nb_module.dylib    [Mac OS x]
nb_module.dll    [Windows]

RULES

  Here we use the Tree node module included in the NodeBrain distribution to illustrate how a module is referenced in rules (commands). The Tree module implements a table using a tree structure internally. In this example, we define two Tree nodes---one for a critical device table and one for a problem device table.

    # declare module - unnecessary if the module is in the standard directory

    declare tree module {"."}tree;

    # declare skill - unnecessary if no special parameters are specified

    declare tree skill tree:trace;

    # table of critical devices

    define criticalDevice node tree;

    # table of problem devices

    define problemDevice node tree;

    # rules that respond when a device has a new problem

    define event node;

    event. define r1 if(type="problem" and ?problemDevice(device)) problemDevice(device):actionA

    event. define r2 if(type="problem" and ?problemDevice(device) and criticalDevice(device)):actionB

    event. define r3 if(type="restored") ?problemDevice(device);

    # sample initialization of the critical device table

    assert criticalDevice("abc");

    assert criticalDevice("def");

    # sample events from a monitoring application

    event. alert type="problem",device="abc";

    event. alert type="restored",device="abc";

ENVIRONMENT

  Some of the C functions nb calls (e.g. for loading dynamic modules) are influenced by environment variables in ways we assume you can figure out for your environment.

NB_MODULE_PATH    The NB_MODULE_PATH environment variable provides a platform independent way of specifying a path for locating node modules. This path overrides the native system search paths by qualifying module names so that a search is avoided. The following example illustrates a setting that directs NodeBrain to search the current directory first and then the parent directory when loading modules (plug-ins).

NB_MODULE_PATH="./:../" nb myscript.nb

DIAGNOSTICS

  If NodeBrain is unable to load a module an error message is displayed.

    yyyy/mm/dd hh:mm:ss NB000E Unable to load file

When a module is successfully loaded but the symbol referenced in a skill declaration is not found, a message is displayed.

    yyyy/mm/dd hh:mm:ss NB000E Symbol symbol not found

NodeBrain does not attempt to load a module when it is declared. Instead, it waits until a module is referenced by a DEFINE command for a node to avoid loading modules unnecessarily. For this reason, either of the messages above will follow a node definition when there is an error.

HISTORY

  Node modules (plug-ins) were introduced in NodeBrain prototype release 0.6.0 in April, 2004.

BUGS

  See nb(1). Please report bugs to <bugs@nodebrain.org> or enter a bug report at http://nodebrain.org.

AUTHOR

  Ed Trettevik <eat@nodebrain.org>

DOCUMENTATION

  Online documentation is available at http://nodebrain.org. Manuals are also available in Texinfo format in the git repository. These documents are included in source distribution files.

SEE ALSO

  nodebrain(7), nb(1), nb.cfg(5), nb.syn(5), nbkit(1), nbkit-caboodle(7)

NodeBrain 0.9.03December 2014nb.mod(7)