From nobody@FreeBSD.org  Sat Feb 26 19:52:32 2011
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 58C7F1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Feb 2011 19:52:32 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 3CBE58FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Feb 2011 19:52:32 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id p1QJqVjJ015621
	for <freebsd-gnats-submit@FreeBSD.org>; Sat, 26 Feb 2011 19:52:31 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id p1QJqVhe015620;
	Sat, 26 Feb 2011 19:52:31 GMT
	(envelope-from nobody)
Message-Id: <201102261952.p1QJqVhe015620@red.freebsd.org>
Date: Sat, 26 Feb 2011 19:52:31 GMT
From: Helmut Schneider <jumper99@gmx.de>
To: freebsd-gnats-submit@FreeBSD.org
Subject: net-mgmt/net-snmp: ssRawCpu* incorrectly calculated
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         155072
>Category:       ports
>Synopsis:       net-mgmt/net-snmp: ssRawCpu* incorrectly calculated
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sylvio
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Feb 26 20:00:18 UTC 2011
>Closed-Date:    Wed Jul 27 20:19:52 UTC 2011
>Last-Modified:  Wed Jul 27 20:19:52 UTC 2011
>Originator:     Helmut Schneider
>Release:        8.1-RELEASE-p2
>Organization:
>Environment:
>Description:
ssRawCpu* is a value that shows the usage of e.g. system, user, nice and idle. Every integer stands for 1/100th of CPU usage. So e.g. ssCpuIdle should increase to 60 seconds * 100 = 6000 per minute per CPU. Analogously ssCpuRawUser and ssCpuSystem should increase to the same amount at fully load. You can check this e.g. with any Linux distribution.

net-snmp 5.5 (tested) on FreeBSD 8.1 i386 and amd64 (tested) increases to a value of ~ 6000*3/4 which is ~33% too high:

[helmut@BSDHelmut832 ~]$ snmpwalk -v2c -cpublic localhost .1.3.6.1.4.1.2021.11; sleep 60; snmpwalk -v2c -cpublic localhost .1.3.6.1.4.1.2021.11
[...]
UCD-SNMP-MIB::ssCpuUser.0 = INTEGER: 99
UCD-SNMP-MIB::ssCpuSystem.0 = INTEGER: 0
UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 0
UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 1158132
UCD-SNMP-MIB::ssCpuRawNice.0 = Counter32: 19759
UCD-SNMP-MIB::ssCpuRawSystem.0 = Counter32: 145467
UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 30152171
UCD-SNMP-MIB::ssCpuRawWait.0 = Counter32: 0
UCD-SNMP-MIB::ssCpuRawKernel.0 = Counter32: 144653
UCD-SNMP-MIB::ssCpuRawInterrupt.0 = Counter32: 814
[...]
UCD-SNMP-MIB::ssCpuRawSoftIRQ.0 = Counter32: 0
[...]
#### second run:
UCD-SNMP-MIB::ssCpuUser.0 = INTEGER: 99
UCD-SNMP-MIB::ssCpuSystem.0 = INTEGER: 0
UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 0
UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 1166104
UCD-SNMP-MIB::ssCpuRawNice.0 = Counter32: 19759
UCD-SNMP-MIB::ssCpuRawSystem.0 = Counter32: 145499
UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 30152171
UCD-SNMP-MIB::ssCpuRawWait.0 = Counter32: 0
UCD-SNMP-MIB::ssCpuRawKernel.0 = Counter32: 144684
UCD-SNMP-MIB::ssCpuRawInterrupt.0 = Counter32: 815
[...]
UCD-SNMP-MIB::ssCpuRawSoftIRQ.0 = Counter32: 0
[...]
[helmut@BSDHelmut832 ~]$

1st: UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 30152171
2nd: UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 30152171

1st: UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 1158132
2nd: UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 1166104

1st: UCD-SNMP-MIB::ssCpuRawSystem.0 = Counter32: 145467
2nd: UCD-SNMP-MIB::ssCpuRawSystem.0 = Counter32: 145499

1st: UCD-SNMP-MIB::ssCpuRawNice.0 = Counter32: 19759
2nd: UCD-SNMP-MIB::ssCpuRawNice.0 = Counter32: 19759

1158132 - 1166104 = -7972

helmut@ubuntu:~$ snmpwalk -v2c -cpublic localhost .1.3.6.1.4.1.2021.11; sleep 60; snmpwalk -v2c -cpublic localhost .1.3.6.1.4.1.2021.11
[...]
UCD-SNMP-MIB::ssCpuUser.0 = INTEGER: 99
UCD-SNMP-MIB::ssCpuSystem.0 = INTEGER: 0
UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 0
UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 22881
UCD-SNMP-MIB::ssCpuRawNice.0 = Counter32: 0
UCD-SNMP-MIB::ssCpuRawSystem.0 = Counter32: 9750
UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 7555837
UCD-SNMP-MIB::ssCpuRawWait.0 = Counter32: 17298
UCD-SNMP-MIB::ssCpuRawKernel.0 = Counter32: 0
UCD-SNMP-MIB::ssCpuRawInterrupt.0 = Counter32: 65
[...]
UCD-SNMP-MIB::ssCpuRawSoftIRQ.0 = Counter32: 236
##### Second run
UCD-SNMP-MIB::ssCpuUser.0 = INTEGER: 99
UCD-SNMP-MIB::ssCpuSystem.0 = INTEGER: 0
UCD-SNMP-MIB::ssCpuIdle.0 = INTEGER: 0
UCD-SNMP-MIB::ssCpuRawUser.0 = Counter32: 28874
UCD-SNMP-MIB::ssCpuRawNice.0 = Counter32: 0
UCD-SNMP-MIB::ssCpuRawSystem.0 = Counter32: 9753
UCD-SNMP-MIB::ssCpuRawIdle.0 = Counter32: 7555837
UCD-SNMP-MIB::ssCpuRawWait.0 = Counter32: 17298
UCD-SNMP-MIB::ssCpuRawKernel.0 = Counter32: 0
UCD-SNMP-MIB::ssCpuRawInterrupt.0 = Counter32: 65
UCD-SNMP-MIB::ssCpuRawSoftIRQ.0 = Counter32: 236
[...]
helmut@ubuntu:~$

22881 - 28874 = -5993

That results in the following graphs:

1) Single CPU Ubuntu 10.04: http://www.charlieroot.de/downloads/Ubuntu-10.04-x86-single-core.jpg
2) Single CPU FreeBSD 8.1 x86: http://www.charlieroot.de/downloads/FreeBSD-x86-single-core.jpg
3) Quad-Core CPU FreeBSD 8.1 amd64: http://www.charlieroot.de/downloads/FreeBSD-amd64-quad-core.jpg

None of those CPUs supports HT.

The load was created with:

perl -e 'while (--$ARGV[0] and fork) {}; while () {}' ${CPU_COUNT}
>How-To-Repeat:
Install net-snmp, create load, query snmpd.
>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->sylvio 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Sat Feb 26 20:00:31 UTC 2011 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155072 

From: "Y. A." <nexther0@gmail.com>
To: bug-followup@freebsd.org, jumper99@gmx.de
Cc:  
Subject: Re: ports/155072: net-mgmt/net-snmp: ssRawCpu* incorrectly calculated
Date: Tue, 15 Mar 2011 21:11:46 +0200

 check 'stathz' value from '>sysctl kern.clockrate' output and you
 understand why your calculation produce such results.
 
 wbr, Y.A.

From: "Helmut Schneider" <jumper99@gmx.de>
To: "Y. A." <nexther0@gmail.com>,
	<bug-followup@freebsd.org>
Cc:  
Subject: Re: ports/155072: net-mgmt/net-snmp: ssRawCpu* incorrectly calculated
Date: Tue, 15 Mar 2011 21:52:10 +0100

 Hi,
 
 From: "Y. A." <nexther0@gmail.com>
 > check 'stathz' value from '>sysctl kern.clockrate' output and you
 > understand why your calculation produce such results.
 
 I now understand what's happening, anyway, shouldn't net-snmp respect 
 kern.clockrate then to calculate the correct CPU usage?
 
 Helmut 
 

From: John Baldwin <jhb@FreeBSD.org>
To: bug-followup@FreeBSD.org, jumper99@gmx.de
Cc:  
Subject: Re: ports/155072: net-mgmt/net-snmp: ssRawCpu* incorrectly calculated
Date: Wed, 20 Jul 2011 08:20:36 -0400

 This is not a bug.  There is no hard and fast requirement that the 
 ssCpuRaw fields are 1/100ths of a second.  The text from the MIB 
 description for ssCpuRawUser reads:
 
 ssCpuRawUser OBJECT-TYPE
      SYNTAX      Counter32
      MAX-ACCESS  read-only
      STATUS      current
      DESCRIPTION
          "The number of 'ticks' (typically 1/100s) spent
           processing user-level code.
 
           On a multi-processor system, the 'ssCpuRaw*'
           counters are cumulative over all CPUs, so their
           sum will typically be N*100 (for N processors)."
      ::= { systemStats 50 }
 
 typically != must.
 
 If net-snmp tried to downconvert ticks values from stathz to 100 hz it 
 would introduce error.  Note that these are supposed to be "raw" values. 
   It does seem to me that the MIB should include a node that clients can 
 use to determine the scale of the ssCpuRaw* members (e.g. the number of 
 ticks per second (equivalent to stathz)).  Even with FreeBSD the 
 'stathz' value can vary depending on tunables set via loader.conf.
 
 -- 
 John Baldwin
State-Changed-From-To: open->closed 
State-Changed-By: sylvio 
State-Changed-When: Wed Jul 27 20:19:51 UTC 2011 
State-Changed-Why:  
net-snmp was update to 5.7 

http://www.freebsd.org/cgi/query-pr.cgi?pr=155072 
>Unformatted:
