Unbreak: stop using struct ifnet and libkvm for interface stats.
ok robert@
This commit is contained in:
parent
bc90e85984
commit
b7ab7d5e56
@ -1,11 +1,11 @@
|
||||
# $OpenBSD: Makefile,v 1.117 2015/10/30 12:47:40 sthen Exp $
|
||||
# $OpenBSD: Makefile,v 1.118 2015/12/09 17:43:36 jca Exp $
|
||||
|
||||
COMMENT-main = network and application monitoring - agent
|
||||
COMMENT-server = network and application monitoring - server
|
||||
COMMENT-web = network and application monitoring - web frontend
|
||||
|
||||
VERSION = 2.4.6
|
||||
REVISION-main = 1
|
||||
REVISION-main = 2
|
||||
REVISION-server = 0
|
||||
DISTNAME = zabbix-${VERSION}
|
||||
FULLPKGNAME-main = zabbix-agent-${VERSION}
|
||||
|
99
net/zabbix/patches/patch-src_libs_zbxsysinfo_openbsd_net_c
Normal file
99
net/zabbix/patches/patch-src_libs_zbxsysinfo_openbsd_net_c
Normal file
@ -0,0 +1,99 @@
|
||||
$OpenBSD: patch-src_libs_zbxsysinfo_openbsd_net_c,v 1.6 2015/12/09 17:43:36 jca Exp $
|
||||
|
||||
Stop using struct ifnet and libkvm for interface stats.
|
||||
|
||||
--- src/libs/zbxsysinfo/openbsd/net.c.orig Mon Aug 10 10:56:48 2015
|
||||
+++ src/libs/zbxsysinfo/openbsd/net.c Wed Dec 9 18:41:03 2015
|
||||
@@ -24,13 +24,8 @@
|
||||
|
||||
#include <sys/sockio.h>
|
||||
|
||||
-#if OpenBSD >= 201405
|
||||
-# include <net/if_var.h> /* structs ifnet and ifnet_head are defined in this header since OpenBSD 5.5 */
|
||||
-#endif
|
||||
-
|
||||
static struct nlist kernel_symbols[] =
|
||||
{
|
||||
- {"_ifnet", N_UNDF, 0, 0, 0},
|
||||
{"_tcbtable", N_UNDF, 0, 0, 0},
|
||||
{NULL, 0, 0, 0, 0}
|
||||
};
|
||||
@@ -43,11 +38,6 @@ static int get_ifdata(const char *if_name,
|
||||
zbx_uint64_t *tbytes, zbx_uint64_t *tpackets, zbx_uint64_t *terrors,
|
||||
zbx_uint64_t *icollisions, char **error)
|
||||
{
|
||||
- struct ifnet_head head;
|
||||
- struct ifnet *ifp;
|
||||
-
|
||||
- kvm_t *kp;
|
||||
- int len = 0;
|
||||
int ret = SYSINFO_RET_FAIL;
|
||||
|
||||
if (NULL == if_name || '\0' == *if_name)
|
||||
@@ -88,66 +78,7 @@ static int get_ifdata(const char *if_name,
|
||||
if (icollisions)
|
||||
*icollisions = 0;
|
||||
|
||||
- if (NULL != (kp = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL))) /* requires root privileges */
|
||||
{
|
||||
- struct ifnet v;
|
||||
-
|
||||
- if (N_UNDF == kernel_symbols[IFNET_ID].n_type)
|
||||
- if (0 != kvm_nlist(kp, &kernel_symbols[0]))
|
||||
- kernel_symbols[IFNET_ID].n_type = N_UNDF;
|
||||
-
|
||||
- if (N_UNDF != kernel_symbols[IFNET_ID].n_type)
|
||||
- {
|
||||
- len = sizeof(struct ifnet_head);
|
||||
-
|
||||
- if (kvm_read(kp, kernel_symbols[IFNET_ID].n_value, &head, len) >= len)
|
||||
- {
|
||||
- len = sizeof(struct ifnet);
|
||||
-
|
||||
- for (ifp = head.tqh_first; ifp; ifp = v.if_list.tqe_next)
|
||||
- {
|
||||
- if (kvm_read(kp, (u_long)ifp, &v, len) < len)
|
||||
- break;
|
||||
-
|
||||
- if (0 == strcmp(if_name, v.if_xname))
|
||||
- {
|
||||
- if (ibytes)
|
||||
- *ibytes += v.if_ibytes;
|
||||
- if (ipackets)
|
||||
- *ipackets += v.if_ipackets;
|
||||
- if (ierrors)
|
||||
- *ierrors += v.if_ierrors;
|
||||
- if (idropped)
|
||||
- *idropped += v.if_iqdrops;
|
||||
- if (obytes)
|
||||
- *obytes += v.if_obytes;
|
||||
- if (opackets)
|
||||
- *opackets += v.if_opackets;
|
||||
- if (oerrors)
|
||||
- *oerrors += v.if_oerrors;
|
||||
- if (tbytes)
|
||||
- *tbytes += v.if_ibytes + v.if_obytes;
|
||||
- if (tpackets)
|
||||
- *tpackets += v.if_ipackets + v.if_opackets;
|
||||
- if (terrors)
|
||||
- *terrors += v.if_ierrors + v.if_oerrors;
|
||||
- if (icollisions)
|
||||
- *icollisions += v.if_collisions;
|
||||
-
|
||||
- ret = SYSINFO_RET_OK;
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- }
|
||||
- kvm_close(kp);
|
||||
-
|
||||
- if (SYSINFO_RET_FAIL == ret)
|
||||
- *error = zbx_strdup(NULL, "Cannot find information for this network interface.");
|
||||
- }
|
||||
- else
|
||||
- {
|
||||
- /* fallback to using SIOCGIFDATA */
|
||||
-
|
||||
int if_s;
|
||||
struct ifreq ifr;
|
||||
struct if_data v;
|
Loading…
Reference in New Issue
Block a user