diff --git a/pkg/datasource.go b/pkg/datasource.go new file mode 100644 index 0000000..e72f843 --- /dev/null +++ b/pkg/datasource.go @@ -0,0 +1,17 @@ +package main + +import ( + "github.com/grafana/grafana_plugin_model/go/datasource" + hclog "github.com/hashicorp/go-hclog" + plugin "github.com/hashicorp/go-plugin" + "golang.org/x/net/context" +) + +type ZabbixDatasource struct { + plugin.NetRPCUnsupportedPlugin + logger hclog.Logger +} + +func (ds *ZabbixDatasource) Query(ctx context.Context, tsdbReq *datasource.DatasourceRequest) (*datasource.DatasourceResponse, error) { + return nil, ctx.Err() +} diff --git a/pkg/models.go b/pkg/models.go new file mode 100644 index 0000000..06ab7d0 --- /dev/null +++ b/pkg/models.go @@ -0,0 +1 @@ +package main diff --git a/pkg/plugin.go b/pkg/plugin.go new file mode 100644 index 0000000..151887c --- /dev/null +++ b/pkg/plugin.go @@ -0,0 +1,33 @@ +package main + +import ( + "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: &ZabbixDatasource{ + logger: pluginLogger, + }}, + }, + + // A non-nil value here enables gRPC serving for this plugin... + GRPCServer: plugin.DefaultGRPCServer, + }) +} diff --git a/src/datasource-zabbix/plugin.json b/src/datasource-zabbix/plugin.json index 2e33d85..4f8618b 100644 --- a/src/datasource-zabbix/plugin.json +++ b/src/datasource-zabbix/plugin.json @@ -3,6 +3,13 @@ "name": "Zabbix", "id": "alexanderzobnin-zabbix-datasource", + "metrics": true, + "annotations": true, + + "backend": true, + "alerting": false, + "executable": "../zabbix-plugin", + "includes": [ { "type": "dashboard", @@ -21,9 +28,6 @@ } ], - "metrics": true, - "annotations": true, - "queryOptions": { "maxDataPoints": true },