Snap Plugin Library helps developers writing plugins (like collectors and publishers) that are able to work in Snap environment:
- a collector is a small application whose role is to gather metrics from a monitored system (like CPU usage, db metrics, etc.)
- a publisher is a small application whose role is to send metrics to a specific backend
The library natively supports Go language, although writing Python plugins is also supported via Cgo integration. There is a plan for supporting other programming languages as well.
The currently active and maintained version is v2.
For a simple development setup you don't need any dependencies outside this repository. Please refer to Testing for more information.
For a complete development setup please refer to AppOptics Knowledge Base
Writing a simple plugin code in Go is very straightforward:
package main
import (
"github.com/solarwinds/snap-plugin-lib/v2/plugin"
"github.com/solarwinds/snap-plugin-lib/v2/runner"
)
type myCollector struct {}
func (c *myCollector) Collect(ctx plugin.CollectContext) error {
_ = ctx.AddMetric("/example/static/value", 34)
return nil
}
func main() {
runner.StartCollector(&myCollector{}, "example-collector", "1.0.0")
}
The same functionality in Python:
from swisnap_plugin_lib_py import BaseCollector, start_collector
class ExamplePlugin(BaseCollector):
def collect(self, ctx):
ctx.add_metric("/example/metric/value", 45)
if __name__ == '__main__':
start_collector(ExamplePlugin("example", "0.0.1"))
More complicated examples can be found in:
- (Go) Examples folder
- (Go) Tutorial
- (Python) Collector Example
- (Python) Publisher Example
- (C#) Collector Example
Plugin Library contains a comprehensive tutorial describing how to write custom plugins.
Covered topics:
- Always check if the problem wasn't already reported by other developers.
- Please fill in Issue submission form.
-
General:
- Make sure that the library is compiling without errors,
- Make sure that ALL unit tests pass,
- Try to add the accompanying test case,
- It's OK to have multiple small commits as you work on the PR - they will be squashed before merging,
- Provide meaningful commit messages.
-
For issues:
- Add issue number to your PR title for a better release log.
-
For a new development:
- Provide a convincing reason to add this feature.
The repository contains a legacy version of Plugin Library (v1) which is no longer supported either by SolarWinds or Intel (which is originally forked from). New defects raised for v1 won't be fixed by maintainers.
Please use v2 for new development.
Links:
- Documentation of Ver. 1
- Community plugins list (no longer maintained)