37 lines
903 B
Go
37 lines
903 B
Go
package main
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/grafana/grafana_plugin_model/go/datasource"
|
|
hclog "github.com/hashicorp/go-hclog"
|
|
plugin "github.com/hashicorp/go-plugin"
|
|
)
|
|
|
|
var pluginLogger = hclog.New(&hclog.LoggerOptions{
|
|
Name: "zabbix-datasource",
|
|
Level: hclog.LevelFromString("DEBUG"),
|
|
})
|
|
|
|
func main() {
|
|
pluginLogger.Debug("Running Zabbix backend datasource")
|
|
|
|
plugin.Serve(&plugin.ServeConfig{
|
|
|
|
HandshakeConfig: plugin.HandshakeConfig{
|
|
ProtocolVersion: 1,
|
|
MagicCookieKey: "grafana_plugin_type",
|
|
MagicCookieValue: "datasource",
|
|
},
|
|
Plugins: map[string]plugin.Plugin{
|
|
"zabbix-backend-datasource": &datasource.DatasourcePluginImpl{Plugin: &ZabbixPlugin{
|
|
datasourceCache: NewCache(10*time.Minute, 10*time.Minute),
|
|
logger: pluginLogger,
|
|
}},
|
|
},
|
|
|
|
// A non-nil value here enables gRPC serving for this plugin...
|
|
GRPCServer: plugin.DefaultGRPCServer,
|
|
})
|
|
}
|