[ previous ] [ next ] [ threads ]
 From:  Audun Larsen <larsen at xqus dot com>
 To:  m0n0wall at lists dot m0n0 dot ch
 Subject:  Re: [m0n0wall] CPU & Memory Usage are really awesome!
 Date:  Sat, 09 Oct 2004 13:58:00 +0200
Timothy Jans wrote:
 > The CPU & Memory Usage in 1.2b1 are really awesome,
 > they are just so much better then the previous load averages.
 > I'm interested, how did you generate the CPU & Memory Usage?

The CPU usage is calculated using /sbin/sysctl kern.cp_time.
This is called two times with one second pause between. The command 
returns cpu time used by: user, nice, sys, intr and idle. With this 
information we can calculate the CPU usage.

The memory usage is also calculated using sysctl.
If you request vm.stats.vm.v_active_count, vm.stats.vm.v_inactive_count, 
vm.stats.vm.v_wire_count, vm.stats.vm.v_cache_count and 
vm.stats.vm.v_free_count it's not difficult to calculate how much free 
memory you have. :)

 > -Timothy

    O   (=>  Audun Larsen
  )/\,_[__]   Larsen Konsult