Ember+ loadable plugin
Source
// GetEmber handles ember.get metric, returns collection data based on request metrics, response needs to be handled,
/*
** Copyright (C) 2001-2024 Zabbix SIA
**
** This program is free software: you can redistribute it and/or modify it under the terms of
** the GNU Affero General Public License as published by the Free Software Foundation, version 3.
**
** This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
** without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
** See the GNU Affero General Public License for more details.
**
** You should have received a copy of the GNU Affero General Public License along with this program.
** If not, see <https://www.gnu.org/licenses/>.
**/
package plugin
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"golang.zabbix.com/plugin/ember-plus/ember"
"golang.zabbix.com/plugin/ember-plus/ember/asn1"
"golang.zabbix.com/plugin/ember-plus/ember/s101"
"golang.zabbix.com/plugin/ember-plus/plugin/conn"
"golang.zabbix.com/plugin/ember-plus/plugin/params"
"golang.zabbix.com/sdk/errs"
"golang.zabbix.com/sdk/metric"
"golang.zabbix.com/sdk/plugin"
"golang.zabbix.com/sdk/plugin/container"
"golang.zabbix.com/sdk/zbxerr"
)
const (
// Name is the name of the plugin.
Name = "EmberPlus"
get = emberMetricKey("ember.get")
)
var (
_ plugin.Configurator = (*emberPlugin)(nil)
_ plugin.Exporter = (*emberPlugin)(nil)
_ plugin.Runner = (*emberPlugin)(nil)
_ handlerFunc = (*emberPlugin)(nil).GetEmber
// ErrInvalidPath error when incorrect path is provided.
ErrInvalidPath = errs.New("invalid path")
)
// HandlerFunc describes the signature all metric handler functions must have.
type handlerFunc func(metricParams map[string]string, extraParams ...string) (any, error)
type emberMetricKey string
type emberMetric struct {
metric *metric.Metric
handler handlerFunc
}
type emberPlugin struct {
plugin.Base