Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Feb 2005 13:30:32 +0100
From:      Nimnod <nimnod@gnu.univ.gda.pl>
To:        freebsd-hackers@freebsd.org
Subject:   how to calculate CPU utilization?
Message-ID:  <opsl23o6hf5x937e@localhost.kolonianet.pl>

next in thread | raw e-mail | index | archive | help
Hi,

i am looking for how to accurately calculate the CPU utilization per  
process.
i have looked through the top sources, and found out it's using the kvm  
lib, which isn't suitable for my purpose.
is there a way to accurately calculate %CPU based on information from the  
struct proc ? it does carry info on proc time (p_runtime), system, user  
and interrupt ticks, and previous system, user and int times in usec, but  
i just can't make the right equation to get the appropriate values.
first, i attempted to divide the process runtime by system uptime, which  
seemed ok, but obviously this is not the way.
could anyone please help?

rgds,
	Nimnod.



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