Re: auto_nlist failed on cp_time at location 1

2008-04-24 Thread Danny Braniss
 
 --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
   [EMAIL PROTECTED]
 
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.0 
 -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@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-stable
 To unsubscribe, send any mail to [EMAIL PROTECTED]
 --dc+cDN39EJAMEtIO--
 


___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: auto_nlist failed on cp_time at location 1

2008-04-24 Thread Tim Stoddard
I cannot get your patch to apply.  Am I doing something wrong?

--
Tim 


#cp patch-cpu_nlist.c /usr/ports/net-mgmt/net-snmp/files/
#cd /usr/ports/net-mgmt/net-snmp
#make clean
===  Cleaning for net-snmp-5.4.1_2
#make

You may use the following build options:

WITH_TKMIB=yesInstall a graphical Perl/Tk/SNMP based mib browser
WITHOUT_DUMMY_VALUES=yesProvide 'placeholder' dummy values where
the necessary information is not available.
WITHOUT_PERL=yesDo not install the perl modules along with the rest
of the net-snmp toolkit.
WITHOUT_IPV6=yesDisable IPv6.

DEFAULT_SNMP_VERSION=3Default version of SNMP to use.
NET_SNMP_SYS_CONTACT=[EMAIL PROTECTED]
Default system contact.
NET_SNMP_SYS_LOCATION=somewhere
Default system location.
NET_SNMP_LOGFILE=/var/log/snmpd.log
Default log file location for snmpd.
NET_SNMP_PERSISTENTDIR=/var/net-snmp
Default directory for persistent data storage.
NET_SNMP_MIB_MODULES=host disman/event-mib smux mibII/mta_sendmail 
mibII/tcpTable ucd-snmp/diskio
Optional mib modules that can be built into the
agent

===  Vulnerability check disabled, database not found
===  Extracting for net-snmp-5.4.1_2
= MD5 Checksum OK for net-snmp-5.4.1.tar.gz.
= SHA256 Checksum OK for net-snmp-5.4.1.tar.gz.
===   net-snmp-5.4.1_2 depends on file: /usr/local/bin/perl5.8.8 - found
===  Patching for net-snmp-5.4.1_2
===   net-snmp-5.4.1_2 depends on file: /usr/local/bin/perl5.8.8 - found
===  Applying extra patch 
/usr/ports/net-mgmt/net-snmp/files/extra-patch-local:Makefile.in
===  Applying FreeBSD patches for net-snmp-5.4.1_2
4 out of 4 hunks failed--saving rejects to 
agent/mibgroup/hardware/cpu/cpu_nlist.c.rej
= Patch patch-cpu_nlist.c failed to apply cleanly.
= Patch(es) patch-Makefile.in patch-callback.c applied cleanly.
*** Error code 1

Stop in /usr/ports/net-mgmt/net-snmp.



 Date: Wed, 23 Apr 2008 20:34:21 -0500
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 CC: freebsd-stable@freebsd.org
 Subject: Re: auto_nlist failed on cp_time at location 1
 
 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
   [EMAIL PROTECTED]

_
Make i'm yours.  Create a custom banner to support your cause.
http://im.live.com/Messenger/IM/Contribute/Default.aspx?source=TXT_TAGHM_MSN_Make_IM_Yours___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: auto_nlist failed on cp_time at location 1

2008-04-24 Thread Tim Stoddard
I applied your patch by hand and recompiled/reinstalled net-snmp, however I am 
still seeing the same error just on a different memory address now.  

Apr 24 10:16:41 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
kvm_read: Bad address
Apr 24 10:16:41 shaggy snmpd[73273]: auto_nlist failed on cp_time at location 1
Apr 24 10:16:46 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
kvm_read: Bad address
Apr 24 10:16:46 shaggy snmpd[73273]: auto_nlist failed on cp_time at location 1
Apr 24 10:16:51 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
kvm_read: Bad address
Apr 24 10:16:51 shaggy snmpd[73273]: auto_nlist failed on cp_time at location 1


--
Tim Stoddard

 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]; freebsd-stable@freebsd.org
 Date: Thu, 24 Apr 2008 07:23:21 -0500
 CC: 
 Subject: RE: auto_nlist failed on cp_time at location 1
 
 I cannot get your patch to apply.  Am I doing something wrong?
 
 --
 Tim 
 
 
 #cp patch-cpu_nlist.c /usr/ports/net-mgmt/net-snmp/files/
 #cd /usr/ports/net-mgmt/net-snmp
 #make clean
 ===  Cleaning for net-snmp-5.4.1_2
 #make
 
 You may use the following build options:
 
 WITH_TKMIB=yesInstall a graphical Perl/Tk/SNMP based mib browser
 WITHOUT_DUMMY_VALUES=yesProvide 'placeholder' dummy values where
 the necessary information is not available.
 WITHOUT_PERL=yesDo not install the perl modules along with the rest
 of the net-snmp toolkit.
 WITHOUT_IPV6=yesDisable IPv6.
 
 DEFAULT_SNMP_VERSION=3Default version of SNMP to use.
 NET_SNMP_SYS_CONTACT=[EMAIL PROTECTED]
 Default system contact.
 NET_SNMP_SYS_LOCATION=somewhere
 Default system location.
 NET_SNMP_LOGFILE=/var/log/snmpd.log
 Default log file location for snmpd.
 NET_SNMP_PERSISTENTDIR=/var/net-snmp
 Default directory for persistent data storage.
 NET_SNMP_MIB_MODULES=host disman/event-mib smux mibII/mta_sendmail 
 mibII/tcpTable ucd-snmp/diskio
 Optional mib modules that can be built into the
 agent
 
 ===  Vulnerability check disabled, database not found
 ===  Extracting for net-snmp-5.4.1_2
 = MD5 Checksum OK for net-snmp-5.4.1.tar.gz.
 = SHA256 Checksum OK for net-snmp-5.4.1.tar.gz.
 ===   net-snmp-5.4.1_2 depends on file: /usr/local/bin/perl5.8.8 - found
 ===  Patching for net-snmp-5.4.1_2
 ===   net-snmp-5.4.1_2 depends on file: /usr/local/bin/perl5.8.8 - found
 ===  Applying extra patch 
 /usr/ports/net-mgmt/net-snmp/files/extra-patch-local:Makefile.in
 ===  Applying FreeBSD patches for net-snmp-5.4.1_2
 4 out of 4 hunks failed--saving rejects to 
 agent/mibgroup/hardware/cpu/cpu_nlist.c.rej
 = Patch patch-cpu_nlist.c failed to apply cleanly.
 = Patch(es) patch-Makefile.in patch-callback.c applied cleanly.
 *** Error code 1
 
 Stop in /usr/ports/net-mgmt/net-snmp.
 
 
 
  Date: Wed, 23 Apr 2008 20:34:21 -0500
  From: [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  CC: freebsd-stable@freebsd.org
  Subject: Re: auto_nlist failed on cp_time at location 1
  
  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
  [EMAIL PROTECTED]
 
 _
 Make i'm yours.  Create a custom banner to support your cause.
 http://im.live.com/Messenger/IM/Contribute/Default.aspx?source=TXT_TAGHM_MSN_Make_IM_Yours___
 freebsd-stable@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/freebsd-stable
 To unsubscribe, send any mail to [EMAIL PROTECTED]

_
Make i'm yours.  Create a custom banner to support your cause.
http://im.live.com/Messenger/IM/Contribute/Default.aspx?source=TXT_TAGHM_MSN_Make_IM_Yours___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: auto_nlist failed on cp_time at location 1

2008-04-24 Thread Dan Nelson
In the last episode (Apr 24), Tim Stoddard said:
 I applied your patch by hand and recompiled/reinstalled net-snmp,
 however I am still seeing the same error just on a different memory
 address now.
 
 Apr 24 10:16:41 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
 kvm_read: Bad address
 Apr 24 10:16:41 shaggy snmpd[73273]: auto_nlist failed on cp_time at location 
 1
 Apr 24 10:16:46 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
 kvm_read: Bad address
 Apr 24 10:16:46 shaggy snmpd[73273]: auto_nlist failed on cp_time at location 
 1
 Apr 24 10:16:51 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
 kvm_read: Bad address
 Apr 24 10:16:51 shaggy snmpd[73273]: auto_nlist failed on cp_time at location 
 1

Hm.  It looks like net-snmp has two different pieces of code that both
do the same thing (read CPU and vmstat info).  I wonder which OIDs
trigger them on your system?  On my system, walking
enterprises.ucdavis.systemStats uses the cpu_nlist.c code.  Here's a
patch for the other file (vmstat_freebsd2.c); it's not even compiled on
my 7-stable system, so I can't verify that it's correct.  I'm not sure
why my first patch didn't apply; I attached it straight out of my
net-snmp/files/ directory.

-- 
Dan Nelson
[EMAIL PROTECTED]
--- agent/mibgroup/ucd-snmp/vmstat_freebsd2.c   2008-04-24 10:25:59.834152091 
-0500
+++ agent/mibgroup/ucd-snmp/vmstat_freebsd2.c   2008-04-24 10:25:59.834152091 
-0500
@@ -189,13 +189,15 @@
  * Update structures (only if time has passed) 
  */
 if (time_new != time_old) {
+int size;
 time_diff = time_new - time_old;
 time_old = time_new;
 
 /*
  * CPU usage 
  */
-auto_nlist(CPTIME_SYMBOL, (char *) cpu_new, sizeof(cpu_new));
+size = sizeof(cpu_new);
+sysctlbyname(kern.cp_time, cpu_new, size, NULL, 0);
 
 cpu_total = 0;
 
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]

RE: auto_nlist failed on cp_time at location 1

2008-04-24 Thread Tim Stoddard
Dan,

I reapplied the first patch you send (this time properly) and it fix the issue. 
 I hope the port maintainer can get your patch committed so other do not have 
to go though the same process.  

Thanks for the help.

--
Tim Stoddard

 Date: Thu, 24 Apr 2008 10:57:07 -0500
 From: [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 CC: freebsd-stable@freebsd.org
 Subject: Re: auto_nlist failed on cp_time at location 1
 
 In the last episode (Apr 24), Tim Stoddard said:
  I applied your patch by hand and recompiled/reinstalled net-snmp,
  however I am still seeing the same error just on a different memory
  address now.
  
  Apr 24 10:16:41 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
  kvm_read: Bad address
  Apr 24 10:16:41 shaggy snmpd[73273]: auto_nlist failed on cp_time at 
  location 1
  Apr 24 10:16:46 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
  kvm_read: Bad address
  Apr 24 10:16:46 shaggy snmpd[73273]: auto_nlist failed on cp_time at 
  location 1
  Apr 24 10:16:51 shaggy snmpd[73273]: kvm_read(*, 1, 0xbf7fe830, 20) = -1: 
  kvm_read: Bad address
  Apr 24 10:16:51 shaggy snmpd[73273]: auto_nlist failed on cp_time at 
  location 1
 
 Hm.  It looks like net-snmp has two different pieces of code that both
 do the same thing (read CPU and vmstat info).  I wonder which OIDs
 trigger them on your system?  On my system, walking
 enterprises.ucdavis.systemStats uses the cpu_nlist.c code.  Here's a
 patch for the other file (vmstat_freebsd2.c); it's not even compiled on
 my 7-stable system, so I can't verify that it's correct.  I'm not sure
 why my first patch didn't apply; I attached it straight out of my
 net-snmp/files/ directory.
 
 -- 
   Dan Nelson
   [EMAIL PROTECTED]

_
Express yourself wherever you are. Mobilize!
http://www.gowindowslive.com/Mobile/Landing/Messenger/Default.aspx?Locale=en-US?ocid=TAG_APRIL___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


auto_nlist failed on cp_time at location 1

2008-04-23 Thread Tim Stoddard
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.  


My upgrade process:
make buildworld
make buildkernel
make installkernel
make installworld
mergemaster
portupgrade -f net-snmp

#pkg_info |grep snmp
net-snmp-5.4.1_2An extendable SNMP implementation


Apr 23 16:02:47 shaggy snmpd[662]: kvm_read(*, 1, 0xbfbfea50, 20) = -1: 
kvm_read: Bad address
Apr 23 16:02:47 shaggy snmpd[662]: auto_nlist failed on cp_time at location 1
Apr 23 16:02:52 shaggy snmpd[662]: kvm_read(*, 1, 0xbfbfea50, 20) = -1: 
kvm_read: Bad address
Apr 23 16:02:52 shaggy snmpd[662]: auto_nlist failed on cp_time at location 1
Apr 23 16:02:57 shaggy snmpd[662]: kvm_read(*, 1, 0xbfbfea50, 20) = -1: 
kvm_read: Bad address
Apr 23 16:02:57 shaggy snmpd[662]: auto_nlist failed on cp_time at location 1
Apr 23 16:03:02 shaggy snmpd[662]: kvm_read(*, 1, 0xbfbfea50, 20) = -1: 
kvm_read: Bad address
Apr 23 16:03:02 shaggy snmpd[662]: auto_nlist failed on cp_time at location 1

--
Tim Stoddard


_
Spell a grand slam in this game where word skill meets World Series. Get in the 
game.
http://club.live.com/word_slugger.aspx?icid=word_slugger_wlhm_admod_april08___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: auto_nlist failed on cp_time at location 1

2008-04-23 Thread Dan Nelson
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
[EMAIL PROTECTED]
--- agent/mibgroup/hardware/cpu/cpu_nlist.c 2007-01-19 10:53:44.0 
-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++ ) {
___
freebsd-stable@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-stable
To unsubscribe, send any mail to [EMAIL PROTECTED]