Date: Tue, 5 May 2009 16:55:39 -0500 From: Dan Nelson <dnelson@allantgroup.com> To: Maxim Khitrov <mkhitrov@gmail.com> Cc: Free BSD Questions list <freebsd-questions@freebsd.org> Subject: Re: Measuring CPU usage via SNMP Message-ID: <20090505215539.GE3371@dan.emsphone.com> In-Reply-To: <26ddd1750905051039y67bed9a5g6e1419b57b9e74fe@mail.gmail.com> References: <26ddd1750905051039y67bed9a5g6e1419b57b9e74fe@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (May 05), Maxim Khitrov said: > Simple question - does the sum of differences in ssCpuRawIdle, > ssCpuRawUser, ssCpuRawNice, ssCpuRawKernel, and ssCpuRawInterrupt OIDs on > a FreeBSD 7.2 system give me total CPU allocation (i.e. is a constant)? > I've configured a few scripts to read these values from bsnmpd, store them > via rrdtool, and then generate a single graph with idle on the negative y > axis and everything else stacked on top. I want to make sure that no > other counter is missing from this ensemble and the ones listed do not > overlap. If either of those conditions is not met, my usage percent > calculation will not be accurate. > > The OIDs that I left out are: > > ssCpuRawSoftIRQ - documentation states that this is for Linux only, > but FreeBSD 7.2 does provide a value for it > ssCpuRawWait - always 0? > ssCpuRawSystem - seems to be a sum of ssCpuRawKernel and ssCpuRawInterrupt > > As far as I can tell, these three do not factor into the equation. The > only one I'm not sure about is ssCpuRawSystem. Is there ever a time when > it will not equal to ssCpuRawKernel + ssCpuRawInterrupt? The nice thing about open source software is you can read the source and see what's going on :) The FreeBSD kernel statclock() function: http://fxr.watson.org/fxr/source/kern/kern_clock.c#L442 updates the cp_time[] array, and it increments one of CP_NICE, CP_USER, CP_INTR, CP_SYS, and CP_IDLE on each tick. The Net-SNMP var_extensible_vmstat() function: http://net-snmp.svn.sourceforge.net/viewvc/net-snmp/trunk/net-snmp/agent/mibgroup/ucd-snmp/vmstat_freebsd2.c?revision=HEAD&view=markup#l_165 fetches that array and maps those indexes to CPURAWNICE, CPURAWUSER, CPURAWINTR, CPURAWKERNEL, and CPURAWIDLE. So fetching the matching ssCpuRaw* oids and totaling them up should always equal 100% cpu. -- Dan Nelson dnelson@allantgroup.com
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20090505215539.GE3371>