** 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 General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
** 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 General Public License for more details.
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
var Metrics map[string]*Metric = make(map[string]*Metric)
var Plugins map[string]Accessor = make(map[string]Accessor)
func registerMetric(plugin Accessor, name string, key string, description string) {
if ok, _ := regexp.MatchString(`^[A-Za-z0-9\._-]+$`, key); !ok {
panic(fmt.Sprintf(`cannot register metric "%s" having invalid format`, key))
if 0 == len(description) {
panic(fmt.Sprintf(`cannot register metric "%s" with empty description`, key))
if unicode.IsLower([]rune(description)[0]) {
panic(fmt.Sprintf(`cannot register metric "%s" with description without capital first letter: "%s"`, key, description))
if description[len(description)-1] != '.' {
panic(fmt.Sprintf(`cannot register metric "%s" without dot at the end of description: "%s"`, key, description))
if _, ok := Metrics[key]; ok {
panic(fmt.Sprintf(`cannot register duplicate metric "%s"`, key))
t := reflect.TypeOf(plugin)
for i := 0; i < t.NumMethod(); i++ {