Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 Jun 2010 18:09:25 +0200
From:      Ulrich =?utf-8?B?U3DDtnJsZWlu?= <uqs@spoerlein.net>
To:        Gustau =?utf-8?B?UMOpcmV6?= <gperez@entel.upc.edu>
Cc:        freebsd-current@freebsd.org
Subject:   Re: Patch for really fixing bsnmpd hrProcessorLoad values
Message-ID:  <20100609160925.GY39829@acme.spoerlein.net>
In-Reply-To: <4C0F8DC6.806@entel.upc.edu>
References:  <20100609104857.GM39829@acme.spoerlein.net> <4C0F8DC6.806@entel.upc.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, 09.06.2010 at 14:49:10 +0200, Gustau Pérez wrote:
> En/na Ulrich Spörlein ha escrit:
> > Hi guys,
> >
> > I finally got fed up with bsnmpd no longer returning the right CPU load
> > values when running under ULE. After taking a look at how top(1) does
> > it, I came up with the following initial patch to bsnmpd, that seems to
> > DTRT.
> >
> > A few technical questions remain:
> >
> > - Is the idle state guaranteed to always be in the last cp_time column?
> > - Is handling overflow of kern.cp_times worth it? There's only a 60s
> >   window of reporting wrong stats, better than what we have now anyway.
> > - Why is kern.cp_times often times *way* longer than hw.ncpu *
> >   CPUSTATES? Is it guaranteed that the first n entries correspond to the
> >   first n*CPUSTATES values in kern.cp_times? Can there be holes?
> >
> > Patch has been tested on 8-STABLE, 4xCPUs and SCHED_ULE. Other reports
> > would be very much appreciated.
> >
> > Regards,
> > Uli
> >
>   Hi Uli,
> 
>   I've just recompiled a RELENG_8_0 kernel, with SCHED_ULE, 2xQuad
> Core and your patch applied to /usr/src. I get 0 values for all
> processors :
> 
> *****************************************************************************
> 
> [root@host ~]# snmpwalk -v 2c -c host IP_HOST | grep hrProcessor
> HOST-RESOURCES-MIB::hrProcessorFrwID.6 = OID: SNMPv2-SMI::zeroDotZero
> HOST-RESOURCES-MIB::hrProcessorFrwID.10 = OID: SNMPv2-SMI::zeroDotZero
> HOST-RESOURCES-MIB::hrProcessorFrwID.14 = OID: SNMPv2-SMI::zeroDotZero
> HOST-RESOURCES-MIB::hrProcessorFrwID.18 = OID: SNMPv2-SMI::zeroDotZero
> HOST-RESOURCES-MIB::hrProcessorFrwID.22 = OID: SNMPv2-SMI::zeroDotZero
> HOST-RESOURCES-MIB::hrProcessorFrwID.26 = OID: SNMPv2-SMI::zeroDotZero
> HOST-RESOURCES-MIB::hrProcessorFrwID.30 = OID: SNMPv2-SMI::zeroDotZero
> HOST-RESOURCES-MIB::hrProcessorFrwID.34 = OID: SNMPv2-SMI::zeroDotZero
> HOST-RESOURCES-MIB::hrProcessorLoad.6 = INTEGER: 0
> HOST-RESOURCES-MIB::hrProcessorLoad.10 = INTEGER: 0
> HOST-RESOURCES-MIB::hrProcessorLoad.14 = INTEGER: 0
> HOST-RESOURCES-MIB::hrProcessorLoad.18 = INTEGER: 0
> HOST-RESOURCES-MIB::hrProcessorLoad.22 = INTEGER: 0
> HOST-RESOURCES-MIB::hrProcessorLoad.26 = INTEGER: 0
> HOST-RESOURCES-MIB::hrProcessorLoad.30 = INTEGER: 0
> HOST-RESOURCES-MIB::hrProcessorLoad.34 = INTEGER: 0
> HOST-RESOURCES-MIB::hrSWRunParameters.3655 = STRING: "hrProcessor"
> [root@host ~]# uname -arn
> FreeBSD host 8.0-RELEASE-p3 FreeBSD 8.0-RELEASE-p3 #2: Wed Jun  9
> 14:23:16 CEST 2010     root@host:/usr/obj/usr/src/sys/CUSTOM  i386
> 
> *****************************************************************************
> 
>    If time permits I may try it in CURRENT. But I don't know when I'll
> be able ...
>  
>    Did I do anything wrong ? I applied the patch, recompiled and
> reinstalled $SRC/usr.sbin/bsnmpd, recompiled $PORTS/net-mngt/bsnmp-ucd
> (just in case) and then recompiled and reinstalled the kernel with ULE
> (I was keeping 4BSD, because hrProcessorLoad used to work only with
> 4BSD).

Hello Gustau,

thanks for testing this. I should have mentioned, that bsnmpd needs at
least 30s to gather enough samples for the CPU load. If you still don't
see anything after that, then that's my fault.

Please also make sure you have some load going on. I recommend running

# cpuset -c -l 0 /bin/sh
# while :; do:; done

which will spin while being stuck to CPU 0. If you still don't see
anything, please run bsnmpd in the foreground like this:

# bsnmpd -d -Devents

and you should see debugging output like that:

HRDEBUG: processor_refill_tbl: hw_ncpu=4 detected_processor_count=4
HRDEBUG: save_sample: CPU no. 0 state 0 value 752372
HRDEBUG: save_sample: CPU no. 0 state 1 value 1188915
HRDEBUG: save_sample: CPU no. 0 state 2 value 469569
HRDEBUG: save_sample: CPU no. 0 state 3 value 3115
HRDEBUG: save_sample: CPU no. 0 state 4 value 81501078
HRDEBUG: get_avg_usage: CPU no. 0 delta ticks 6003 pct usage 0.18

Please also provide me with the output of:

# sysctl kern.boottime kern.cp_times hw.ncpu

Thanks!
Uli



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20100609160925.GY39829>