** Copyright (C) 2001-2025 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/>.
"golang.zabbix.com/sdk/errs"
"golang.zabbix.com/sdk/metric"
"golang.zabbix.com/sdk/plugin"
"golang.zabbix.com/sdk/uri"
keyCustomQuery = "mysql.custom.query"
keyDatabasesDiscovery = "mysql.db.discovery"
keyDatabaseSize = "mysql.db.size"
keyReplicationDiscovery = "mysql.replication.discovery"
keyReplicationSlaveStatus = "mysql.replication.get_slave_status"
keyStatusVars = "mysql.get_status_variables"
keyVersion = "mysql.version"
tlsConnectParam = "TLSConnect"
tlsCertParam = "TLSCertFile"
tlsKeyParam = "TLSKeyFile"
masterHostParam = "Master"
uriDefaults = &uri.Defaults{Scheme: "tcp", Port: "3306"}
// Common params: [URI|Session][,User][,Password]
paramURI = metric.NewConnParam(uriParam, "URI to connect or session name.").
WithDefault(uriDefaults.Scheme + "://localhost:" + uriDefaults.Port).WithSession().
WithValidator(uri.URIValidator{Defaults: uriDefaults, AllowedSchemes: []string{"tcp", "unix"}})
paramUsername = metric.NewConnParam("User", "MySQL user.").WithDefault("root")
paramPassword = metric.NewConnParam("Password", "User's password.").WithDefault("")
paramTLSConnect = metric.NewSessionOnlyParam("TLSConnect", "DB connection encryption type.").WithDefault("")
paramTLSCaFile = metric.NewSessionOnlyParam("TLSCAFile", "TLS ca file path.").WithDefault("")
paramTLSCertFile = metric.NewSessionOnlyParam("TLSCertFile", "TLS cert file path.").WithDefault("")
paramTLSKeyFile = metric.NewSessionOnlyParam("TLSKeyFile", "TLS key file path.").WithDefault("")
metrics = metric.MetricSet{
keyCustomQuery: metric.New("Returns result of a custom query.",
paramURI, paramUsername, paramPassword,
metric.NewParam("QueryName", "Name of a custom query "+
"(must be equal to a name of an SQL file without an extension).").SetRequired(),