func (p *Plugin) Export(key string, params []string, ctx plugin.ContextProvider) (result interface{}, err error) {
** 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.org/x/sys/windows"
"golang.zabbix.com/agent2/pkg/win32"
"golang.zabbix.com/sdk/errs"
"golang.zabbix.com/sdk/plugin"
errorEmptyIpTable = "Empty IP address table returned."
errorCannotFindIf = "Cannot obtain network interface information."
err := plugin.RegisterMetrics(
"net.if.list", "Returns a list of network interfaces in text format.",
"net.if.in", "Returns incoming traffic statistics on network interface.",
"net.if.out", "Returns outgoing traffic statistics on network interface.",
"net.if.total", "Returns sum of incoming and outgoing traffic statistics on network interface.",
"net.if.discovery", "Returns list of network interfaces. Used for low-level discovery.",
panic(errs.Wrap(err, "failed to register metrics"))
func (p *Plugin) nToIP(addr uint32) net.IP {
b := (*[4]byte)(unsafe.Pointer(&addr))
return net.IPv4(b[0], b[1], b[2], b[3])
func (p *Plugin) getIpAddrTable() (addrs []win32.MIB_IPADDRROW, err error) {
var ipTable *win32.MIB_IPADDRTABLE
var sizeIn, sizeOut uint32
if sizeOut, err = win32.GetIpAddrTable(nil, 0, false); err != nil {