Distributing Plugins

Debian/Ubuntu

To distribute plugins across multiple Debian/Ubuntu machines, or containers, or virtual machines, it may be handy to create a deb package containing the sources of one or more plugins. The package only have to install plugin sources under /usr/share/ntopng/scripts/plugins/, which is the default directory ntopng uses to load them.

A skeleton for a deb package ready to distribute plugins is available on GitHub. The skeleton can be used to create a minimal .deb file. It is suitable to produce a .deb for personal use but it may not be stringent enough if the package needs to be included in official Debian / Ubuntu repositories. Comprehensive instructions and rules can be found in the Debian New Maintainer’s Guide and in the Ubuntu Packaging Guide.

Example

The following example shows how to create a deb package to distribute the example plugins Blacklisted Flows and Flow Flooders.

First of all, download the skeleton contents. in a local directory, say ntopng-plugins.

The tree of the skeleton is quite simple:

ntopng-plugins/
|-- DEBIAN
|   |-- README.source
|   `-- control
`-- usr
    `-- share
  `-- ntopng
      `-- scripts
    `-- plugins

The root directory ntopng-plugins contains two sub-directories, namely DEBIAN and usr/share/ntopng/scripts/plugins/.

Sub-directory DEBIAN contains a README file which just points to this documentation, and a control file which is basically a descriptor of the package. This file lists package dependencies, maintainer, version, name and other information. Change it to make sure it fits your needs.

The other Sub-directory usr/share/ntopng/scripts/plugins/ is just the path which will be used by the package installer to place the files in the destination system during package installation. Place in this sub-directory the plugins to be installed.

To distribute Blacklisted Flows and Flow Flooders, copy their whole plugin directories under ntopng-plugins package sub-directory usr/share/ntopng/scripts/plugins/. After the copy, the final structure of the package directory ntopng-plugins becomes

ntopng-plugins/
|-- DEBIAN
|   |-- README.source
|   `-- control
`-- usr
    `-- share
  `-- ntopng
      `-- scripts
    `-- plugins
        |-- blacklisted
        |   |-- alert_definitions
        |   |   `-- alert_flow_blacklisted.lua
        |   |-- manifest.lua
        |   |-- status_definitions
        |   |   `-- status_blacklisted.lua
        |   `-- user_scripts
        |       `-- flow
        |           `-- blacklisted.lua
        `-- flow_flood
      |-- alert_definitions
      |   `-- alert_flows_flood.lua
      |-- manifest.lua
      `-- user_scripts
          |-- host
          |   |-- flow_flood_attacker.lua
          |   `-- flow_flood_victim.lua
          `-- network
        `-- flow_flood_victim.lua

Now everything is ready and setup for the actual creation of the deb. Just jump in the directory which contains ntopng-plugins/ and type the following

$ dpkg-deb --build ntopng-plugins

This will product a .deb file ntopng-plugins.deb ready to be distributed on a repository or manually installed with

$ dpkg -i ntopng-plugins.deb