auto_nlist failed on cp_time at location 1
Danny Braniss
danny at cs.huji.ac.il
Thu Apr 24 08:02:51 UTC 2008
>
> --dc+cDN39EJAMEtIO
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
>
> In the last episode (Apr 23), Tim Stoddard said:
> > I just upgraded from FreeBSD 6.2 ->
> > 6.3 (using source tree). I then recompiled my net-snmp port binaries (using
> > portupgrade). I am now get error message in my logs every five secs.
> > I am sure my libkvm is in sync with my kernel. I do not know what else
> > to look at.
>
> You got bit by
>
> revision 1.178.2.5
> date: 2008/04/09 19:47:20; author: peter; state: Exp; lines: +68 -5
> MFC: record per-cpu stats for %user/%nice/%system/%idle
>
> , which removed the kernel variable that net-snmp uses to track CPU
> usage. Try this patch (put it in /usr/ports/net-mgmt/net-snmp/files and
> rebuild net-snmp). I've sent it to the net-snmp port maintainer so
> hopefully it will be committed soon.
>
> --
> Dan Nelson
> dnelson at allantgroup.com
>
the same goes for rpc.rstatd :-), see
http://www.freebsd.org/cgi/query-pr.cgi?pr=123014
> --dc+cDN39EJAMEtIO
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: attachment; filename="patch-cpu_nlist.c"
>
> --- agent/mibgroup/hardware/cpu/cpu_nlist.c 2007-01-19 10:53:44.000000000 -0600
> +++ agent/mibgroup/hardware/cpu/cpu_nlist.c 2008-04-22 00:13:48.330686919 -0500
> @@ -1,5 +1,5 @@
> /*
> - * nlist() interface
> + * sysctl() interface
> * e.g. FreeBSD
> */
> #include <net-snmp/net-snmp-config.h>
> @@ -12,24 +12,9 @@
> #include <sys/types.h>
> #include <sys/resource.h>
>
> -#ifdef HAVE_SYS_DKSTAT_H
> -#include <sys/dkstat.h>
> -#endif
> #ifdef HAVE_SYS_SYSCTL_H
> #include <sys/sysctl.h>
> #endif
> -#ifdef HAVE_SYS_VMMETER_H
> -#include <sys/vmmeter.h>
> -#endif
> -#ifdef HAVE_VM_VM_PARAM_H
> -#include <vm/vm_param.h>
> -#endif
> -#ifdef HAVE_VM_VM_EXTERN_H
> -#include <vm/vm_extern.h>
> -#endif
> -
> -#define CPU_SYMBOL "cp_time"
> -#define MEM_SYMBOL "cnt"
>
> void _cpu_copy_stats( netsnmp_cpu_info *cpu );
>
> @@ -67,11 +52,12 @@
> */
> int netsnmp_cpu_arch_load( netsnmp_cache *cache, void *magic ) {
> long cpu_stats[CPUSTATES];
> - struct vmmeter mem_stats;
> + int size, tempval;
> +
> netsnmp_cpu_info *cpu = netsnmp_cpu_get_byIdx( -1, 0 );
>
> - auto_nlist( CPU_SYMBOL, (char *) cpu_stats, sizeof(cpu_stats));
> - auto_nlist( MEM_SYMBOL, (char *)&mem_stats, sizeof(mem_stats));
> + size = sizeof(cpu_stats);
> + sysctlbyname("kern.cp_time", &cpu_stats, &size, NULL, 0);
>
> cpu->user_ticks = (unsigned long)cpu_stats[CP_USER];
> cpu->nice_ticks = (unsigned long)cpu_stats[CP_NICE];
> @@ -85,15 +71,19 @@
> * Interrupt/Context Switch statistics
> * XXX - Do these really belong here ?
> */
> -#if defined(openbsd2) || defined(darwin)
> - cpu->swapIn = (unsigned long)mem_stats.v_swpin;
> - cpu->swapOut = (unsigned long)mem_stats.v_swpout;
> -#else
> - cpu->swapIn = (unsigned long)mem_stats.v_swappgsin+mem_stats.v_vnodepgsin;
> - cpu->swapOut = (unsigned long)mem_stats.v_swappgsout+mem_stats.v_vnodepgsout;
> -#endif
> - cpu->nInterrupts = (unsigned long)mem_stats.v_intr;
> - cpu->nCtxSwitches = (unsigned long)mem_stats.v_swtch;
> + size = sizeof(int);
> +#define GET_VM_STATS(cat, name, netsnmpname) \
> + do { \
> + sysctlbyname("vm.stats." #cat "." #name, &tempval, &size, NULL, 0); \
> + cpu->netsnmpname = (unsigned long) tempval; \
> + } while(0)
> +
> + GET_VM_STATS(vm, v_swappgsin, swapIn);
> + GET_VM_STATS(vm, v_swappgsout, swapOut);
> + GET_VM_STATS(vm, v_vnodepgsin, pageIn);
> + GET_VM_STATS(vm, v_vnodepgsout, pageOut);
> + GET_VM_STATS(sys, v_intr, nInterrupts);
> + GET_VM_STATS(sys, v_swtch, nCtxSwitches);
>
> #ifdef PER_CPU_INFO
> for ( i = 0; i < n; i++ ) {
>
> --dc+cDN39EJAMEtIO
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
>
> _______________________________________________
> freebsd-stable at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-stable
> To unsubscribe, send any mail to "freebsd-stable-unsubscribe at freebsd.org"
> --dc+cDN39EJAMEtIO--
>
More information about the freebsd-stable
mailing list