PostgreSQL loadable plugin
Source
/*
** Zabbix
** Copyright 2001-2024 Zabbix SIA
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
**/
package plugin
import (
"context"
"net/http"
"time"
"github.com/omeid/go-yarn"
"golang.zabbix.com/sdk/metric"
"golang.zabbix.com/sdk/plugin"
"golang.zabbix.com/sdk/zbxerr"
)
const (
Name = "PostgreSQL"
sqlExt = ".sql"
hkInterval = 10
)
// Plugin inherits plugin.Base and store plugin-specific data.
type Plugin struct {
plugin.Base
connMgr *ConnManager
options PluginOptions
}
// Impl is the pointer to the plugin implementation.
var Impl Plugin
// Export implements the Exporter interface.
func (p *Plugin) Export(key string, rawParams []string, _ plugin.ContextProvider) (result any, err error) {
params, extraParams, hc, err := metrics[key].EvalParams(rawParams, p.options.Sessions)
if err != nil {
return nil, err
}
err = metric.SetDefaults(params, hc, p.options.Default)
if err != nil {
return nil, err
}
connID, err := createConnID(params)
if err != nil {
return nil, err
}