** 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/agent2/internal/agent"
"golang.zabbix.com/agent2/plugins/external"
"golang.zabbix.com/sdk/errs"
"golang.zabbix.com/sdk/log"
func initExternalPlugins(options *agent.AgentOptions, sysOptions agent.PluginSystemOptions) (string, error) {
paths := make(map[string]string)
for name, s := range sysOptions {
// if path is not set it's an internal plugin
if !filepath.IsAbs(*s.Path) {
return "", errs.Errorf("loadable plugin %q path %q is not absolute", name, *s.Path)
socket := options.ExternalPluginsSocket
err := os.RemoveAll(socket)
return "", errs.Wrapf(err, "failed to remove plugin socket, with path %q", socket)
listener, err := getListener(socket)
return "", errs.Wrap(err, "failed to get socket listener")
for name, path := range paths {
log.Debugf("initializing external plugin %q", name)