diff -u zabbix-2.0.4-dist/src/libs/zbxsysinfo/freebsd/freebsd.c zabbix-2.0.4/src/libs/zbxsysinfo/freebsd/freebsd.c --- zabbix-2.0.4-dist/src/libs/zbxsysinfo/freebsd/freebsd.c 2012-12-08 12:09:15.000000000 +0100 +++ zabbix-2.0.4/src/libs/zbxsysinfo/freebsd/freebsd.c 2013-01-13 11:55:12.933547507 +0100 @@ -40,6 +40,7 @@ {"net.if.out", CF_USEUPARAM, NET_IF_OUT, 0, "lo0,bytes"}, {"net.if.total", CF_USEUPARAM, NET_IF_TOTAL, 0, "lo0,bytes"}, {"net.if.collisions", CF_USEUPARAM, NET_IF_COLLISIONS, 0, "lo0"}, + {"net.if.discovery", 0, NET_IF_DISCOVERY, NULL, NULL}, {"vm.memory.size", CF_USEUPARAM, VM_MEMORY_SIZE, 0, "free"}, diff -u zabbix-2.0.4-dist/src/libs/zbxsysinfo/freebsd/net.c zabbix-2.0.4/src/libs/zbxsysinfo/freebsd/net.c --- zabbix-2.0.4-dist/src/libs/zbxsysinfo/freebsd/net.c 2012-12-08 12:09:15.000000000 +0100 +++ zabbix-2.0.4/src/libs/zbxsysinfo/freebsd/net.c 2013-01-13 11:54:49.954800782 +0100 @@ -20,6 +20,7 @@ #include "common.h" #include "sysinfo.h" #include "../common/common.h" +#include "zbxjson.h" static struct ifmibdata ifmd; @@ -216,3 +217,37 @@ return SYSINFO_RET_OK; } + +int NET_IF_DISCOVERY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) +{ + int ret = SYSINFO_RET_FAIL; + struct zbx_json j; + struct if_nameindex *interfaces; + int i; + + zbx_json_init(&j, ZBX_JSON_STAT_BUF_LEN); + + zbx_json_addarray(&j, ZBX_PROTO_TAG_DATA); + + if ((interfaces=if_nameindex())!=NULL) { + i=0; + + while (interfaces[i].if_index!=0) { + zbx_json_addobject(&j, NULL); + zbx_json_addstring(&j, "{#IFNAME}", interfaces[i].if_name, ZBX_JSON_TYPE_STRING); + zbx_json_close(&j); + i++; + } + + ret = SYSINFO_RET_OK; + } + + zbx_json_close(&j); + + SET_STR_RESULT(result, strdup(j.buffer)); + + zbx_json_free(&j); + + return ret; +} +