From owner-freebsd-stable@FreeBSD.ORG Thu Apr 24 01:34:22 2008 Return-Path: Delivered-To: freebsd-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 856AC1065677 for ; Thu, 24 Apr 2008 01:34:22 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (dan.emsphone.com [199.67.51.101]) by mx1.freebsd.org (Postfix) with ESMTP id 576198FC0A for ; Thu, 24 Apr 2008 01:34:22 +0000 (UTC) (envelope-from dan@dan.emsphone.com) Received: from dan.emsphone.com (smmsp@localhost [127.0.0.1]) by dan.emsphone.com (8.14.2/8.14.2) with ESMTP id m3O1YLl7070244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 23 Apr 2008 20:34:21 -0500 (CDT) (envelope-from dan@dan.emsphone.com) Received: (from dan@localhost) by dan.emsphone.com (8.14.2/8.14.2/Submit) id m3O1YL8q070239; Wed, 23 Apr 2008 20:34:21 -0500 (CDT) (envelope-from dan) Date: Wed, 23 Apr 2008 20:34:21 -0500 From: Dan Nelson To: Tim Stoddard Message-ID: <20080424013421.GF99910@dan.emsphone.com> References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="dc+cDN39EJAMEtIO" Content-Disposition: inline In-Reply-To: X-OS: FreeBSD 7.0-STABLE User-Agent: Mutt/1.5.17 (2007-11-01) Cc: freebsd-stable@freebsd.org Subject: Re: auto_nlist failed on cp_time at location 1 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 Apr 2008 01:34:22 -0000 --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@allantgroup.com --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 @@ -12,24 +12,9 @@ #include #include -#ifdef HAVE_SYS_DKSTAT_H -#include -#endif #ifdef HAVE_SYS_SYSCTL_H #include #endif -#ifdef HAVE_SYS_VMMETER_H -#include -#endif -#ifdef HAVE_VM_VM_PARAM_H -#include -#endif -#ifdef HAVE_VM_VM_EXTERN_H -#include -#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--