Build and installation of a sensor plugin

Considering the dynamic architecture of the udsensors plugins, it only has one dependency with the SenSys plugins library, which contains the symbols of the dataContainer class. Plugins can be installed in any location, and the path should be passed to the monitoring system by means of a MCA variable. There are two methods to build a plugin library:

Build Plugin Library as part of Sensys

To build your plugin as part of the Sensys build system you will need to perform the following steps:

  1. Create a directory for your plugin code under orcm/sensor/udsensor. For example: orcm/sensor/udsensor/rand_generator.

  2. A Makefile.am file for your plugin library is needed. A Makefile for the example rand_generator plugin would look like this:

    rand_generator_sources = \
        rand_generator/rand_generator.hpp \
        rand_generator/rand_generator.cpp
    
    if WITH_RAND_GENERATOR # set if --with-rand-generator=yes option is passed in configure step
        component_install += libudplugin_rand_generator.la
    endif
    
    libudplugin_rand_generator_la_SOURCES = $(rand_generator_sources)
    libudplugin_rand_generator_la_LDFLAGS = -module -avoid-version
    libudplugin_rand_generator_la_LIBADD  = $(top_builddir)/orcm/common/libsensysplugins.la
    

    And it can be found here: orcm/sensor/udsensor/rand_generator/Makefile.am.

    Note: The library name must start with a libudplugin_ prefix, so udsensor can find it and load the plugin.

  3. Include your plugin Makefile in the udsensor Makefile.

    Find the include directive at the end of the orcm/sensor/udsensor/Makefile.am file and append your Makefile.am at the end of the line.

    include rand_generator/Makefile.am
    

    Note: Whitespace is required between include and the file names.

  4. Add a configuration to enable/disable your plugin compilation.

    You could add a configure parameter to specify whether you want your plugin to be compiled or not. To do so, you will need to add something like this in the orcm/mca/sensor/udsensors/configure.m4 file:

    AC_ARG_WITH([rand_generator],
                [AC_HELP_STRING([--with-rand-generator],
                                [Build rand_generator sensor plugin support (default: no)])],
                                [], with_rand_generator=no)
    
    AM_CONDITIONAL([WITH_RAND_GENERATOR], [test "$with_rand_generator" = "yes"])
    

    With this option, you could add --with-rand-generator=yes or --with-rand-generator=no to the ./configure command to enable or disable compilation of your plugin. Another way to do it is by adding with_rand_generator=yes or with_rand_generator=no in your platform configuration file; i.e. contrib/platform/intel/hillsboro/orcm-linux.

    Note: If you use option --with-udsensors=no or with_udsensors=no, any udsensor code or plugin will be built.

  5. Follow steps for building Sensys from source tar or a repository

Build Plugin Library outside Sensys

Assuming the monitoring system is installed in /opt/sensys, and using GNU g++ compiler, the following compilation command can be used:

    g++ -O3 -fPIC -I/opt/sensys/include/openmpi/ -L/opt/sensys/lib/ -shared -rdynamic \
         -lsensysplugins rand_generator.cpp -o libudplugin_rand_generator.so

The following Makefile example can be customized for convenience:

    SENSORPLUGIN=rand_generator
    PLUGINPREFIX=libudplugin_
    CXX=g++
    SENSYSPATH=/opt/sensys
    SENSYSLIBPATH=$(SENSYSPATH)/lib
    PLUGININSTALLPATH=$(SENSYSLIBPATH)/openmpi
    CXXFLAGS=-O3 -fPIC -I$(SENSYSPATH)/include/openmpi/
    LDFLAGS=-L$(SENSYSLIBPATH) -shared -rdynamic -lsensysplugins

    all:
            $(CXX) $(CXXFLAGS) $(LDFLAGS) $(SENSORPLUGIN).cpp -o $(PLUGINPREFIX)$(SENSORPLUGIN).so

    install: all
            install $(PLUGINPREFIX)$(SENSORPLUGIN).so $(PLUGININSSTALLPATH)

    clean:
            -rm *.o
            -rm *.so

Loading plugins into the monitoring system

All of the user defined sensor plugins are being handled by a Sensys sensor plugin named udsensors. The sampling would be performed at the specified sample rate for that plugin, serially requesting the samples to each of the registered plugins.

The following MCA parameters are supported for udsensors:

  • use_progress_thread: Use a dedicated progress thread for udsensors sensors [default: false]. This is a thread for the whole udsensors handler, not for each of the user defined plugins.
  • sample_rate: Sample rate in seconds. As with every other sensor plugin, this sample rate is applicable if the handler is running on its own thread. If not, it will sample at the base sample rate.
  • collect_metrics: Enable metric collection for the udsensors plugin.
  • path : User-defined sensors path. By default, sensors would be searched in the installation path, within the lib/openmpi directory.

Assuming that user defined plugins and headers are located in the default path, the simplest way to start the daemon for sampling udsensors is:

    % orcmd --omca sensor heartbeat,udsensors