diff options
author | christos <christos@pkgsrc.org> | 2013-04-04 19:59:06 +0000 |
---|---|---|
committer | christos <christos@pkgsrc.org> | 2013-04-04 19:59:06 +0000 |
commit | 8773b6736ec86fd37a992fddf8298a39675cd99e (patch) | |
tree | d3fae74c8ade3971503fa980f98b61746e422cf8 /net | |
parent | e0da5ba7ae498caa8290d00d6402d3e13ff97de9 (diff) | |
download | pkgsrc-8773b6736ec86fd37a992fddf8298a39675cd99e.tar.gz |
memory stats -> wrong type in getting some sysctls
cpu stats -> wrong sysctl getting cpu model
process stats -> netbsd5 was not defined leading to wrong process stats
Diffstat (limited to 'net')
4 files changed, 205 insertions, 26 deletions
diff --git a/net/net-snmp/patches/patch-agent_mibgroup_hardware_cpu_cpu__sysctl.c b/net/net-snmp/patches/patch-agent_mibgroup_hardware_cpu_cpu__sysctl.c index 28cfcdf9fd9..66a4dfa22e6 100644 --- a/net/net-snmp/patches/patch-agent_mibgroup_hardware_cpu_cpu__sysctl.c +++ b/net/net-snmp/patches/patch-agent_mibgroup_hardware_cpu_cpu__sysctl.c @@ -1,8 +1,16 @@ -$NetBSD: patch-agent_mibgroup_hardware_cpu_cpu__sysctl.c,v 1.1 2013/03/23 12:23:25 joerg Exp $ +$NetBSD: patch-agent_mibgroup_hardware_cpu_cpu__sysctl.c,v 1.2 2013/04/04 19:59:06 christos Exp $ ---- agent/mibgroup/hardware/cpu/cpu_sysctl.c.orig 2013-03-23 10:53:47.000000000 +0000 -+++ agent/mibgroup/hardware/cpu/cpu_sysctl.c -@@ -24,6 +24,9 @@ +--- agent/mibgroup/hardware/cpu/cpu_sysctl.c.orig 2012-10-09 18:28:58.000000000 -0400 ++++ agent/mibgroup/hardware/cpu/cpu_sysctl.c 2013-04-04 15:33:49.000000000 -0400 +@@ -10,6 +10,7 @@ + + #include <stdlib.h> + #include <unistd.h> ++#include <errno.h> + #include <sys/types.h> + + #if defined(__FreeBSD__) +@@ -24,6 +25,9 @@ #include <sys/param.h> #include <sys/sysctl.h> #include <sys/vmmeter.h> @@ -12,3 +20,68 @@ $NetBSD: patch-agent_mibgroup_hardware_cpu_cpu__sysctl.c,v 1.1 2013/03/23 12:23: #ifdef HAVE_VM_VM_PARAM_H #include <vm/vm_param.h> #endif +@@ -43,7 +47,7 @@ + int i, n; + size_t siz; + int ncpu_mib[] = { CTL_HW, HW_NCPU }; +-#if !(defined(__NetBSD__) && ( defined(__i386__) || defined(__x86_64__) ) ) ++#if !(defined(__FreeBSD__) && ( defined(__i386__) || defined(__x86_64__) ) ) + int model_mib[] = { CTL_HW, HW_MODEL }; + #endif + char descr[ SNMP_MAXBUF ]; +@@ -51,14 +55,17 @@ + strcpy(cpu->name, "Overall CPU statistics"); + + siz = sizeof(n); +- sysctl(ncpu_mib, 2, &n, &siz, NULL, 0); ++ if (sysctl(ncpu_mib, 2, &n, &siz, NULL, 0) == -1) ++ snmp_log(LOG_ERR, "sysctl hw.ncpu failed (errno %d)\n", errno); + if ( n <= 0 ) + n = 1; /* Single CPU system */ + siz = sizeof(descr); +-#if defined(__NetBSD__) && ( defined(__i386__) || defined(__x86_64__) ) +- sysctlbyname("machdep.cpu_brand", descr, &siz, NULL, 0); ++#if defined(__FreeBSD__) && ( defined(__i386__) || defined(__x86_64__) ) ++ if (sysctlbyname("machdep.cpu_brand", descr, &siz, NULL, 0) == -1) ++ snmp_log(LOG_ERR, "sysctl machdep.cpu_brand failed (errno %d)\n", errno) + #else +- sysctl(model_mib, 2, descr, &siz, NULL, 0); ++ if (sysctl(model_mib, 2, descr, &siz, NULL, 0) == -1) ++ snmp_log(LOG_ERR, "sysctl hw.model failed (errno %d)\n", errno); + #endif + for ( i = 0; i < n; i++ ) { + cpu = netsnmp_cpu_get_byIdx( i, 1 ); +@@ -174,9 +181,11 @@ + netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 0 ); + + #if (defined(__FreeBSD__) || defined(__NetBSD__)) +- sysctlbyname("kern.cp_time", cpu_stats, &cpu_size, NULL, 0); ++ if (sysctlbyname("kern.cp_time", cpu_stats, &cpu_size, NULL, 0) == -1) ++ snmp_log(LOG_ERR, "sysctl kern.cp_time failed (errno %d)\n", errno); + #else +- sysctl(cpu_mib, 2, cpu_stats, &cpu_size, NULL, 0); ++ if (sysctl(cpu_mib, 2, cpu_stats, &cpu_size, NULL, 0) == -1) ++ snmp_log(LOG_ERR, "sysctl kern.cpu failed (errno %d)\n", errno); + #endif + cpu->user_ticks = (unsigned long long)cpu_stats[CP_USER]; + cpu->nice_ticks = (unsigned long long)cpu_stats[CP_NICE]; +@@ -190,7 +199,8 @@ + * Interrupt/Context Switch statistics + * XXX - Do these really belong here ? + */ +- sysctl(mem_mib, 2, &mem_stats, &mem_size, NULL, 0); ++ if (sysctl(mem_mib, 2, &mem_stats, &mem_size, NULL, 0) == -1) ++ snmp_log(LOG_ERR, "sysctl vm.vm_meter failed (errno %d)\n", errno); + cpu->nInterrupts = (unsigned long long)mem_stats.NS_VM_INTR; + cpu->nCtxSwitches = (unsigned long long)mem_stats.NS_VM_SWTCH; + cpu->swapIn = (unsigned long long)mem_stats.NS_VM_SWAPIN; +@@ -205,7 +215,8 @@ + #ifdef NETSNMP_KERN_MCPU + mcpu_size = cpu_num*sizeof(NETSNMP_KERN_MCPU_TYPE); + mcpu_stats = malloc(mcpu_size); +- sysctl(mcpu_mib, 2, mcpu_stats, &mcpu_size, NULL, 0); ++ if (sysctl(mcpu_mib, 2, mcpu_stats, &mcpu_size, NULL, 0) == -1) ++ snmp_log(LOG_ERR, "sysctl kern.mcpu failed (errno %d)\n", errno); + for ( i = 0; i < cpu_num; i++ ) { + cpu = netsnmp_cpu_get_byIdx( i, 0 ); + /* XXX - per-CPU statistics - mcpu_mib[i].??? */ diff --git a/net/net-snmp/patches/patch-agent_mibgroup_hardware_memory_memory__netbsd.c b/net/net-snmp/patches/patch-agent_mibgroup_hardware_memory_memory__netbsd.c index 7a38fabbeda..1cc31aa6994 100644 --- a/net/net-snmp/patches/patch-agent_mibgroup_hardware_memory_memory__netbsd.c +++ b/net/net-snmp/patches/patch-agent_mibgroup_hardware_memory_memory__netbsd.c @@ -1,13 +1,107 @@ -$NetBSD: patch-agent_mibgroup_hardware_memory_memory__netbsd.c,v 1.1 2013/03/17 00:18:31 gdt Exp $ +$NetBSD: patch-agent_mibgroup_hardware_memory_memory__netbsd.c,v 1.2 2013/04/04 19:59:07 christos Exp $ ---- agent/mibgroup/hardware/memory/memory_netbsd.c.orig 2012-10-09 22:28:58.000000000 +0000 -+++ agent/mibgroup/hardware/memory/memory_netbsd.c -@@ -174,7 +174,7 @@ int netsnmp_mem_arch_load( netsnmp_cache +--- agent/mibgroup/hardware/memory/memory_netbsd.c.orig 2012-10-09 18:28:58.000000000 -0400 ++++ agent/mibgroup/hardware/memory/memory_netbsd.c 2013-04-04 15:09:23.000000000 -0400 +@@ -48,8 +48,8 @@ + int uvmexp_mib[] = { CTL_VM, VM_UVMEXP }; + int total_mib[] = { CTL_VM, VM_METER }; + #else +- unsigned int bufspace; +- unsigned int maxbufspace; ++ uint64_t bufspace; ++ uint64_t maxbufspace; + size_t buf_size = sizeof(bufspace); + #endif + +@@ -102,6 +102,7 @@ + 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 ); +@@ -113,6 +114,7 @@ + mem->units = pagesize; + mem->size = user_mem/pagesize; + mem->free = uvmexp.free; ++ mem->other = -1; + } + + #if 1 +@@ -125,6 +127,7 @@ + mem->units = pagesize; + mem->size = total.t_vm; + mem->free = total.t_avm; ++ mem->other = -1; + } + + mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_SHARED, 1 ); +@@ -136,6 +139,7 @@ + mem->units = pagesize; + mem->size = total.t_vmshr; + mem->free = total.t_avmshr; ++ mem->other = -1; + } + + mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_SHARED2, 1 ); +@@ -147,6 +151,7 @@ + mem->units = pagesize; + mem->size = total.t_rmshr; + mem->free = total.t_armshr; ++ mem->other = -1; + } + #endif + +@@ -174,7 +179,8 @@ mem->descr = strdup("Memory buffers"); mem->units = 1024; mem->size = maxbufspace /1024; - mem->size = (maxbufspace - bufspace)/1024; + mem->free = (maxbufspace - bufspace)/1024; ++ mem->other = -1; } #endif +@@ -199,18 +205,28 @@ + * If there's only one swap device, don't bother + */ + n = swapctl( SWAP_NSWAP, NULL, 0 ); +- if ( n <= 1 ) ++ if ( n <= 1 ) { ++ if (n == -1) ++ snmp_log_perror("error getting swap"); + return; ++ } + +- s = (struct swapent*)calloc(n, sizeof(struct swapent)); +- swapctl( SWAP_STATS, s, n ); +- ++ s = calloc(n, sizeof(struct swapent)); ++ if (s == NULL) { ++ snmp_log_perror("Out of memory for swap"); ++ return; ++ } ++ if (swapctl( SWAP_STATS, s, n ) == -1) { ++ snmp_log_perror("error getting swap"); ++ return; ++ } + for (i = 0; i < n; ++i) { + mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_SWAP+1+i, 1 ); +- if (!mem) ++ if (!mem) { ++ snmp_log_perror("no swapindex"); + continue; ++ } + if (!mem->descr) { +- /* sprintf(buf, "swap #%d", s[i].se_dev); */ + sprintf(buf, "swap %s", s[i].se_path); + mem->descr = strdup( buf ); + } +@@ -219,5 +235,6 @@ + mem->free = s[i].se_nblks - s[i].se_inuse; + mem->other = -1; + } ++/*###238 [cc] error: expected identifier or '(' before '}' token%%%*/ + } + #endif diff --git a/net/net-snmp/patches/patch-fa b/net/net-snmp/patches/patch-fa deleted file mode 100644 index 64ebf930f4a..00000000000 --- a/net/net-snmp/patches/patch-fa +++ /dev/null @@ -1,18 +0,0 @@ -$NetBSD: patch-fa,v 1.5 2013/03/17 00:15:29 gdt Exp $ - ---- include/net-snmp/system/netbsd.h.orig 2012-10-09 22:28:58.000000000 +0000 -+++ include/net-snmp/system/netbsd.h -@@ -68,6 +68,13 @@ - - #if __NetBSD_Version__ >= 499005800 - #define NETBSD_STATS_VIA_SYSCTL -+ -+/* Why these undefs? */ -+#undef IPSTAT_SYMBOL -+#undef ICMPSTAT_SYMBOL -+#undef TCPSTAT_SYMBOL -+#undef UDPSTAT_SYMBOL -+ - #endif /* __NetBSD_Version__ >= 499005800 */ - - /* define the extra mib modules that are supported */ diff --git a/net/net-snmp/patches/patch-include_net-snmp_system_netbsd.h b/net/net-snmp/patches/patch-include_net-snmp_system_netbsd.h new file mode 100644 index 00000000000..5a2e74db117 --- /dev/null +++ b/net/net-snmp/patches/patch-include_net-snmp_system_netbsd.h @@ -0,0 +1,30 @@ +$NetBSD: patch-include_net-snmp_system_netbsd.h,v 1.1 2013/04/04 19:59:07 christos Exp $ + +--- include/net-snmp/system/netbsd.h.orig 2012-10-09 18:28:58.000000000 -0400 ++++ include/net-snmp/system/netbsd.h 2013-04-04 15:07:09.000000000 -0400 +@@ -33,6 +33,11 @@ + #define UTMP_FILE _PATH_UTMP + + #define UDP_ADDRESSES_IN_HOST_ORDER 1 ++#if __NetBSD_Version__ >= 600000000 && !defined(netbsdelf6) ++#define netbsdelf6 ++#elif __NetBSD_Version__ >= 500000000 && !defined(netbsdelf5) ++#define netbsdelf5 ++#endif + + #ifdef netbsdelf6 + #define netbsd6 +@@ -68,6 +73,13 @@ + + #if __NetBSD_Version__ >= 499005800 + #define NETBSD_STATS_VIA_SYSCTL ++ ++/* Why these undefs? */ ++#undef IPSTAT_SYMBOL ++#undef ICMPSTAT_SYMBOL ++#undef TCPSTAT_SYMBOL ++#undef UDPSTAT_SYMBOL ++ + #endif /* __NetBSD_Version__ >= 499005800 */ + + /* define the extra mib modules that are supported */ |