This is a library for writing plugins in C++ for the Snap telemetry framework.
Snap has three different plugin types. For instructions on how to write a plugin check out the following links to example plugins:
Before writing a Snap plugin:
- See if one already exists in the Plugin Catalog
- See if someone mentioned it in the plugin wishlist
If you do decide to write a plugin, open a new issue following the plugin wishlist guidelines and let us know you are working on one!
Snap is an open and modular telemetry framework designed to simplify the collection, processing and publishing of data through a single HTTP based API. Plugins provide the functionality of collection, processing and publishing and can be loaded/unloaded, upgraded and swapped without requiring a restart of the Snap daemon.
A Snap plugin is a program that responds to a set of well defined gRPC services with parameters and returns types specified as protocol buffer messages (see plugin.proto). The Snap daemon handshakes with the plugin over stdout and then communicates over gRPC.
You will find example plugins that cover the basics for writing collector, processor, and publisher plugins in the examples folder.
Dependencies:
- autoconf
- automake
- curl
- g++
- grpc++ (see below)
- libtool
- make
- spdlog v0.13.0
- boost c++ libs v1.58.0
- cpp-netlib v0.11.2
Plugin currently depends on GRPC 1.0.x, so if your OS's package repository contains another version, it won't be compatible. First, you need to install all dependencies except GRPC, then build GRPC 1.0.x from source.
git clone https://github.com/grpc/grpc
cd grpc
git checkout tags/v1.0.1
git submodule update --init
make
[sudo] make install
Snap plugin library for C++ depends also on protobuf library. As it is already in GRPC dependencies, you can install it like:
cd ./third_party/protobuf
[sudo] make install
$ ./autogen.sh
$ ./configure
$ make
$ [sudo] make install
autotools
installs libsnap
into /usr/local/lib
, which not all linkers use when searching for shared objects. Using the --prefix=/usr
switch when running the configure
script will place the resulting libraries into /usr/lib
, for example.
To clean up and rebuild use:
$ make clean
$ git clean -df # warning! This deletes all dirs and files not checked in. Be sure to check in any new files before running `git clean`.