nb.mod(7) NodeBrain Administrator Guide
Version 0.8.17 - August 2014
nb.mod(7)

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


NAME

  nb.mod - NodeBrain Node Modules (plug-ins)

SYNOPSIS

  #include <nb/nb.h>

int skillAssert (nbCELL context , void * skillHandle , void * knowledgeHandle , nbCELL arglist );

nbCELL skillEvaluate (nbCELL context , void * skillHandle , void * knowledgeHandle , nbCELL arglist );

void * skillBind (nbCELL context ,nbCELL skill ,nbCELL arglist ,char * text ){

    nbSkillSetMethod( context , skill ,NB_EXPERT_ASSERT, skillAssert );

nbSkillSetMethod( context , skill ,NB_EXPERT_EVALUATE, skillEvaluate );

    ... create skillHandle here using arglist and text ...

return( skillHandle );

}

declare module module path/nb_mod_package.(so|dylib|dll);

declare module module [ {"path"} ] [ package [ (args) ] [ ; | :text ]

declare skill skill [ module. ] skill [ (args) ] [ ; | :text ]

define term node [ skill [ (args) ] ] [ ; | :text ]

DESCRIPTION

  NodeBrain modules are dynamic load libraries used as plug-ins to extend the capabilities of NodeBrain, nb(1), using a defined application program interface (API). There is presently only one such interface defined - NodeBrain Node Module C API. Within the context of NodeBrain, we refer to modules that use this interface simply as "node modules." A node module implements one or more 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. A NodeBrain Library manual has been started, but needs a lot work.

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

FILES

 

/usr/local/include/nb/nb.h    NodeBrain API header file.
/usr/local/lib/nb/x.x/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 /usr/local/lib/nb/x.x as show above, where suffix is determined by the platform.
nb_mod_module.so    [Solaris and Linux]
nb_mod_module.sl    [HP-UX]
nb_mod_module.dylib    [Mac OS x]
nb_mod_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

  Although node modules were supported in prior releases on Linux, Solaris, HP-UX, OS X, and Windows, release 0.8.15 has only been tested on Linux.

For a complete and current list of bugs, you should refer to the project web site.

Please report bugs by linking to the project page from the home page, http://www.nodebrain.org, or send email to <bugs@nodebrain.org>.

AUTHOR

  Ed Trettevik <eat@nodebrain.org>

SEE ALSO

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

[1] NodeBrain Home Page

[2] NodeBrain Tutorial

[3] NodeBrain Language Reference


NodeBrain 0.8.17August 2014nb.mod(7)