summaryrefslogtreecommitdiff
path: root/net/net-snmp
diff options
context:
space:
mode:
authorsekiya <sekiya@pkgsrc.org>2010-12-26 09:23:49 +0000
committersekiya <sekiya@pkgsrc.org>2010-12-26 09:23:49 +0000
commita517a84265ad33593d81be5272d42c9a1927474a (patch)
tree59900353c8708ce6a09d3c4abb482f839bd41738 /net/net-snmp
parent8b16dda86019a0d92f910255cc62fcce366626d8 (diff)
downloadpkgsrc-a517a84265ad33593d81be5272d42c9a1927474a.tar.gz
Pull memory statistics properly, and fix an overflow in the CPU statistics.
("netbsdelf3", indeed ... )
Diffstat (limited to 'net/net-snmp')
-rw-r--r--net/net-snmp/Makefile4
-rw-r--r--net/net-snmp/distinfo5
-rw-r--r--net/net-snmp/patches/patch-ah133
-rw-r--r--net/net-snmp/patches/patch-fd57
4 files changed, 170 insertions, 29 deletions
diff --git a/net/net-snmp/Makefile b/net/net-snmp/Makefile
index 7e330bab4c1..8304187740c 100644
--- a/net/net-snmp/Makefile
+++ b/net/net-snmp/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.83 2010/12/22 08:13:30 sekiya Exp $
+# $NetBSD: Makefile,v 1.84 2010/12/26 09:23:49 sekiya Exp $
DISTNAME= net-snmp-5.4.3
-PKGREVISION= 2
+PKGREVISION= 3
CATEGORIES= net
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=net-snmp/}
diff --git a/net/net-snmp/distinfo b/net/net-snmp/distinfo
index ca54f0a246b..0aaeedcd916 100644
--- a/net/net-snmp/distinfo
+++ b/net/net-snmp/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.58 2010/12/22 08:13:30 sekiya Exp $
+$NetBSD: distinfo,v 1.59 2010/12/26 09:23:49 sekiya Exp $
SHA1 (net-snmp-5.4.3.tar.gz) = 849a20ddeaa90b1b0010e487876927e615b5c6bc
RMD160 (net-snmp-5.4.3.tar.gz) = 417f47c301c3221a64f37162b56b4661c9f6d8cb
@@ -10,7 +10,7 @@ SHA1 (patch-ad) = 33342943740508e38527cc5c049adcbd2cb56b8f
SHA1 (patch-ae) = f2aa891feb0e1e1d85cd6bf7f9daed92c5955112
SHA1 (patch-af) = 3fd6b61199bf47673dcfd10aae6a81ef2c4b33ab
SHA1 (patch-ag) = 7021f7238c37635c9c32ceca681fd42aa125437f
-SHA1 (patch-ah) = 7d4a6fa1cc370da2301da952dabdb996b52fb0f7
+SHA1 (patch-ah) = 7cea4194c858d7a8a9093eaf4426404e9202c3f1
SHA1 (patch-ai) = c57baca06856187115db39fd50668203dad0a94c
SHA1 (patch-aj) = 30c28c4801cea33d54e68bbde603e7d531dfb2f8
SHA1 (patch-ak) = cccad21d4f56e79799a433ef7bf0e8ff4e917afb
@@ -54,3 +54,4 @@ SHA1 (patch-ez) = dc7ef797733fd930f2a3dacb8c28151371706dfc
SHA1 (patch-fa) = 9478aa624fbdc82b54d1e7f50f4e2ee0518dcb92
SHA1 (patch-fb) = 64d97a51d82488ef4d3ea5dd40278501975d58fb
SHA1 (patch-fc) = 4e0b9841cbff0da02748efc9105096ffcbe58e81
+SHA1 (patch-fd) = 6411ba28f0e9a9b66e22f3fbc71ca207cfd6bdd7
diff --git a/net/net-snmp/patches/patch-ah b/net/net-snmp/patches/patch-ah
index ab80b70dfc0..e85b0a46825 100644
--- a/net/net-snmp/patches/patch-ah
+++ b/net/net-snmp/patches/patch-ah
@@ -1,35 +1,39 @@
-$NetBSD: patch-ah,v 1.5 2010/05/11 04:39:54 adam Exp $
+$NetBSD: patch-ah,v 1.6 2010/12/26 09:23:49 sekiya Exp $
---- agent/mibgroup/hardware/memory/memory_netbsd.c.orig 2006-03-06 16:23:52.000000000 +0000
-+++ agent/mibgroup/hardware/memory/memory_netbsd.c 2010-04-21 21:58:02.000000000 +0000
-@@ -4,6 +4,7 @@
+--- agent/mibgroup/hardware/memory/memory_netbsd.c.orig 2006-03-07 01:23:52.000000000 +0900
++++ agent/mibgroup/hardware/memory/memory_netbsd.c 2010-12-26 17:50:43.000000000 +0900
+@@ -4,7 +4,9 @@
#include <net-snmp/agent/hardware/memory.h>
#include <unistd.h>
+#include <errno.h>
#include <sys/sysctl.h>
++#include <sys/vmmeter.h>
#include <sys/swap.h>
-@@ -30,7 +31,7 @@
+ #if defined(HAVE_UVM_UVM_PARAM_H) && defined(HAVE_UVM_UVM_EXTERN_H)
+@@ -30,27 +32,47 @@
long pagesize;
struct uvmexp uvmexp;
- int uvmexp_size = sizeof(uvmexp);
+- int uvmexp_mib[] = { CTL_VM, VM_UVMEXP };
+ size_t uvmexp_size = sizeof(uvmexp);
- int uvmexp_mib[] = { CTL_VM, VM_UVMEXP };
struct vmtotal total;
-@@ -40,16 +41,33 @@
- long phys_mem;
- long user_mem;
+ size_t total_size = sizeof(total);
+- int total_mib[] = { CTL_VM, VM_METER };
+
+- long phys_mem;
+- long user_mem;
++ quad_t phys_mem;
++ quad_t user_mem;
++ unsigned int bufspace;
++ unsigned int maxbufspace;
size_t mem_size = sizeof(phys_mem);
-+#if defined(__x86_64__)
-+ int phys_mem_mib[] = { CTL_HW, HW_PHYSMEM64 };
-+ int user_mem_mib[] = { CTL_HW, HW_USERMEM64 };
-+#else
- int phys_mem_mib[] = { CTL_HW, HW_PHYSMEM };
- int user_mem_mib[] = { CTL_HW, HW_USERMEM };
-+#endif
+- int phys_mem_mib[] = { CTL_HW, HW_PHYSMEM };
+- int user_mem_mib[] = { CTL_HW, HW_USERMEM };
++ size_t buf_size = sizeof(bufspace);
/*
* Retrieve the memory information from the underlying O/S...
@@ -38,22 +42,101 @@ $NetBSD: patch-ah,v 1.5 2010/05/11 04:39:54 adam Exp $
- sysctl(total_mib, 2, &total, &total_size, NULL, 0);
- sysctl(phys_mem_mib, 2, &phys_mem, &mem_size, NULL, 0);
- sysctl(user_mem_mib, 2, &user_mem, &mem_size, NULL, 0);
-+ if (sysctl(uvmexp_mib, 2, &uvmexp, &uvmexp_size, NULL, 0) == -1) {
-+ snmp_log(LOG_ERR, "sysctl VM_UVMEXP failed (errno %d)\n", errno);
+- pagesize = uvmexp.pagesize;
++ if (sysctlbyname("vm.uvmexp", &uvmexp, &uvmexp_size, NULL, 0) == -1) {
++ snmp_log(LOG_ERR, "sysctl vm.uvmexp failed (errno %d)\n", errno);
++ return -1;
++ }
++ if (sysctlbyname("vm.vmmeter", &total, &total_size, NULL, 0) == -1) {
++ snmp_log(LOG_ERR, "sysctl vm.vmmeter failed (errno %d)\n", errno);
+ return -1;
+ }
-+ if (sysctl(total_mib, 2, &total, &total_size, NULL, 0) == -1) {
-+ snmp_log(LOG_ERR, "sysctl VM_METER failed (errno %d)\n", errno);
++ if (sysctlbyname("hw.physmem64", &phys_mem, &mem_size, NULL, 0) == -1) {
++ snmp_log(LOG_ERR, "sysctl hw.physmem64 failed (errno %d)\n", errno);
+ return -1;
+ }
-+ if (sysctl(phys_mem_mib, 2, &phys_mem, &mem_size, NULL, 0) == -1) {
-+ snmp_log(LOG_ERR, "sysctl HW_PHYSMEM failed (errno %d)\n", errno);
++ if (sysctlbyname("hw.usermem64", &user_mem, &mem_size, NULL, 0) == -1) {
++ snmp_log(LOG_ERR, "sysctl hw.usermem64 failed (errno %d)\n", errno);
+ return -1;
+ }
-+ if (sysctl(user_mem_mib, 2, &user_mem, &mem_size, NULL, 0) == -1) {
-+ snmp_log(LOG_ERR, "sysctl HW_USERMEM failed (errno %d)\n", errno);
++ if (sysctlbyname("vm.bufmem", &bufspace, &buf_size, NULL, 0) == -1) {
++ snmp_log(LOG_ERR, "sysctl vm.bufmem failed (errno %d)\n", errno);
+ return -1;
+ }
- pagesize = uvmexp.pagesize;
++ if (sysctlbyname("vm.bufmem_hiwater", &maxbufspace, &buf_size, NULL, 0) == -1) {
++ snmp_log(LOG_ERR, "sysctl vm.bufmem_hiwater failed (errno %d)\n", errno);
++ return -1;
++ }
++
++ pagesize = sysconf(_SC_PAGESIZE);
/*
+ * ... and save this in a standard form.
+@@ -64,7 +86,6 @@
+ mem->units = pagesize;
+ mem->size = phys_mem/pagesize;
+ mem->free = total.t_free;
+- mem->other = -1;
+ }
+
+ mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_USERMEM, 1 );
+@@ -76,7 +97,39 @@
+ mem->units = pagesize;
+ mem->size = user_mem/pagesize;
+ mem->free = uvmexp.free;
+- mem->other = -1;
++ }
++
++ mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_VIRTMEM, 1 );
++ if (!mem) {
++ snmp_log_perror("No Virtual Memory info entry");
++ } else {
++ if (!mem->descr)
++ mem->descr = strdup("Virtual memory");
++ mem->units = pagesize;
++ mem->size = total.t_vm;
++ mem->free = total.t_avm;
++ }
++
++ mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_SHARED, 1 );
++ if (!mem) {
++ snmp_log_perror("No Shared Memory info entry");
++ } else {
++ if (!mem->descr)
++ mem->descr = strdup("Shared virtual memory");
++ mem->units = pagesize;
++ mem->size = total.t_vmshr;
++ mem->free = total.t_avmshr;
++ }
++
++ mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_SHARED2, 1 );
++ if (!mem) {
++ snmp_log_perror("No Shared2 Memory info entry");
++ } else {
++ if (!mem->descr)
++ mem->descr = strdup("Shared real memory");
++ mem->units = pagesize;
++ mem->size = total.t_rmshr;
++ mem->free = total.t_armshr;
+ }
+
+ #ifdef SWAP_NSWAP
+@@ -91,7 +144,17 @@
+ mem->units = pagesize;
+ mem->size = uvmexp.swpages;
+ mem->free = uvmexp.swpages - uvmexp.swpginuse;
+- mem->other = -1;
++ }
++
++ mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_MBUF, 1 );
++ if (!mem) {
++ snmp_log_perror("No Buffer, etc info entry");
++ } else {
++ if (!mem->descr)
++ mem->descr = strdup("Memory buffers");
++ mem->units = 1024;
++ mem->size = maxbufspace / 1024;
++ mem->free = (maxbufspace - bufspace)/1024;
+ }
+
+ return 0;
diff --git a/net/net-snmp/patches/patch-fd b/net/net-snmp/patches/patch-fd
new file mode 100644
index 00000000000..bb17fdd7e94
--- /dev/null
+++ b/net/net-snmp/patches/patch-fd
@@ -0,0 +1,57 @@
+$NetBSD: patch-fd,v 1.1 2010/12/26 09:23:49 sekiya Exp $
+
+--- agent/mibgroup/hardware/cpu/cpu_sysctl.c.orig 2010-12-26 16:45:27.000000000 +0900
++++ agent/mibgroup/hardware/cpu/cpu_sysctl.c 2010-12-26 17:14:36.000000000 +0900
+@@ -49,7 +49,11 @@
+ if ( n <= 0 )
+ n = 1; /* Single CPU system */
+ i = sizeof(descr);
++#if defined(__NetBSD__) && ( defined(__i386__) || defined(__x86_64__) )
++ sysctlbyname("machdep.cpu_brand", descr, (void *)&i, NULL, 0);
++#else
+ sysctl(model_mib, 2, descr, (void *)&i, NULL, 0);
++#endif
+ for ( i = 0; i < n; i++ ) {
+ cpu = netsnmp_cpu_get_byIdx( i, 1 );
+ cpu->status = 2; /* running */
+@@ -59,26 +63,22 @@
+ cpu_num = n;
+ }
+
+-
++#if defined(__NetBSD__)
++#define NETSNMP_CPU_STATS uint64_t
++#define NETSNMP_KERN_CPU KERN_CP_TIME
++#else
+ #define NETSNMP_CPU_STATS long
+ #if defined(KERN_CPUSTATS) /* BSDi */
+ #define NETSNMP_KERN_CPU KERN_CPUSTATS
+ #elif defined(KERN_CPTIME) /* OpenBSD */
+ #define NETSNMP_KERN_CPU KERN_CPTIME
+-#elif defined(KERN_CP_TIME) /* NetBSD */
+-#define NETSNMP_KERN_CPU KERN_CP_TIME
+-
+-#if defined(netbsdelf3)
+-#undef NETSNMP_CPU_STATS
+-#define NETSNMP_CPU_STATS uint64_t
+-#endif
+-
+ #elif defined(__FreeBSD__)
+ #define NETSNMP_KERN_CPU 0 /* dummy value - sysctlnametomib(2) should be used */
+
+ #else
+ #error "No CPU statistics sysctl token"
+ #endif
++#endif
+
+ /*
+ Need to check details before enabling this!
+@@ -159,7 +159,7 @@
+ size_t mem_size = sizeof(NETSNMP_VM_STATS_TYPE);
+ netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 0 );
+
+-#if defined(__FreeBSD__)
++#if defined(__FreeBSD__) || defined (__NetBSD__)
+ sysctlbyname("kern.cp_time", cpu_stats, &cpu_size, NULL, 0);
+ #else
+ sysctl(cpu_mib, 2, cpu_stats, &cpu_size, NULL, 0);