svn commit: r438995 - in head/net-mgmt/net-snmp: . files
Gleb Smirnoff
glebius at FreeBSD.org
Thu Apr 20 22:16:01 UTC 2017
Author: glebius (src committer)
Date: Thu Apr 20 22:16:00 2017
New Revision: 438995
URL: https://svnweb.freebsd.org/changeset/ports/438995
Log:
Fixing net-snmpd after src revision r317061 (struct vmmeter changes),
I discovered that net-snmpd tries to read { CTL_VM, VM_TOTAL } mib into
'struct vmmeter' variable, instead of 'struct vmtotal'. Of course,
sysctl(3) fails, but net-snmpd doesn't check for errors. Basicly this
is broken for all supported FreeBSD versions, and I believe for all
unsupported as well. OIDs that report interruprs, context switches,
paging and swap in/out were returning garbage from the application
stack.
To patch that problem, provide dummy struct __vmmeter, which works
both on pre-r317061 and after, and add block of code that reads all
necessary stats one by one. To keep with the style of the file, do
not check for errors from sysctl(3).
Added:
head/net-mgmt/net-snmp/files/patch-agent_mibgroup_hardware_cpu_cpu_sysctl.c (contents, props changed)
Modified:
head/net-mgmt/net-snmp/Makefile
Modified: head/net-mgmt/net-snmp/Makefile
==============================================================================
--- head/net-mgmt/net-snmp/Makefile Thu Apr 20 20:55:21 2017 (r438994)
+++ head/net-mgmt/net-snmp/Makefile Thu Apr 20 22:16:00 2017 (r438995)
@@ -3,7 +3,7 @@
PORTNAME= snmp
PORTVERSION= 5.7.3
-PORTREVISION= 15
+PORTREVISION= 16
CATEGORIES= net-mgmt ipv6
MASTER_SITES= SF/net-${PORTNAME}/net-${PORTNAME}/${PORTVERSION}
PKGNAMEPREFIX= net-
Added: head/net-mgmt/net-snmp/files/patch-agent_mibgroup_hardware_cpu_cpu_sysctl.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/net-mgmt/net-snmp/files/patch-agent_mibgroup_hardware_cpu_cpu_sysctl.c Thu Apr 20 22:16:00 2017 (r438995)
@@ -0,0 +1,49 @@
+--- agent/mibgroup/hardware/cpu/cpu_sysctl.c.orig 2014-12-08 12:23:22.000000000 -0800
++++ agent/mibgroup/hardware/cpu/cpu_sysctl.c 2017-04-20 15:05:11.607496000 -0700
+@@ -130,8 +130,21 @@
+ #endif /* VM_UVMEXP2 || VM_UVMEXP */
+
+ #elif defined(__FreeBSD__) /* FreeBSD */
++#if __FreeBSD_version >= 1200028
++#define VMMETER_TYPE uint64_t
++#else
++#define VMMETER_TYPE u_int
++#endif
++struct __vmmeter {
++ VMMETER_TYPE v_intr;
++ VMMETER_TYPE v_swtch;
++ VMMETER_TYPE v_swappgsin;
++ VMMETER_TYPE v_swappgsout;
++ VMMETER_TYPE v_swapin;
++ VMMETER_TYPE v_swapout;
++};
+ #define NETSNMP_VM_STATS VM_METER
+-#define NETSNMP_VM_STATS_TYPE struct vmmeter
++#define NETSNMP_VM_STATS_TYPE struct __vmmeter
+ #define NS_VM_INTR v_intr
+ #define NS_VM_SWTCH v_swtch
+ #define NS_VM_PAGEIN v_swappgsin
+@@ -206,7 +219,23 @@
+ * Interrupt/Context Switch statistics
+ * XXX - Do these really belong here ?
+ */
++#ifdef __FreeBSD__
++#define GET_VM_STATS(space, name) sysctlbyname("vm.stats." #space "." #name, &mem_stats.name, &len, NULL, 0)
++ {
++ size_t len;
++
++ len = sizeof(VMMETER_TYPE);
++ GET_VM_STATS(sys, v_intr);
++ GET_VM_STATS(sys, v_swtch);
++ GET_VM_STATS(vm, v_swappgsin);
++ GET_VM_STATS(vm, v_swappgsout);
++ GET_VM_STATS(vm, v_swapin);
++ GET_VM_STATS(vm, v_swapout);
++ }
++#undef GET_VM_STATS
++#else
+ sysctl(mem_mib, 2, &mem_stats, &mem_size, NULL, 0);
++#endif
+ cpu->nInterrupts = mem_stats.NS_VM_INTR;
+ cpu->nCtxSwitches = mem_stats.NS_VM_SWTCH;
+ cpu->swapIn = mem_stats.NS_VM_SWAPIN;
More information about the svn-ports-head
mailing list