How to find out the cpu usage, real & virtual memory usage ?

How to find out the cpu usage, real & virtual memory usage ?

Post by Jae Chu » Thu, 18 Oct 2001 16:07:45



Hi
I am supposed to write a small application (agent) that reports the
cpu usage, real(physical) memory and virtual meomry usage of a host to
a system management application (ie the manager) via tcp/ip.

I have a few questions regarding working out the total cpu usage, the
total amount of physical and virtual memory being used by all
processes running on a workstation.

The first question is, I have learnt that the use of the kstat/kvm API
will give me the access to such parameters but I havent been able to
find enough information on this.  so If anyone can point me to the
right direction I will be very thankful. I have looked thru the books
that came with the OS but no luck there.

The second question, and probably a more fundamemtal one is that, from
what Ive heard from the SUN help desk, it isnt possible to work out
the total amount of physical memory used by all processses on a
system, even if I can figure out how much is being used by a given
process, since there is no way to find out how much memory is shared
between processes (e.g shared library). I was wondering if anyone from
this NG can confirm this.
If that is the case, that I guess I will have to make do with the sum
of the amounts of memory each process occupies, which will somehow be
larger than the actual amount of the physical memory being used.

Any help will be much appreciated, TIA.

 
 
 

How to find out the cpu usage, real & virtual memory usage ?

Post by Andreas Almrot » Thu, 18 Oct 2001 17:40:07



> Hi
> I am supposed to write a small application (agent) that reports the
> cpu usage, real(physical) memory and virtual meomry usage of a host to
> a system management application (ie the manager) via tcp/ip.

> I have a few questions regarding working out the total cpu usage, the
> total amount of physical and virtual memory being used by all
> processes running on a workstation.

> The first question is, I have learnt that the use of the kstat/kvm API
> will give me the access to such parameters but I havent been able to
> find enough information on this.  so If anyone can point me to the
> right direction I will be very thankful. I have looked thru the books
> that came with the OS but no luck there.

I had the similar questions a week ago, and I got two recommendations;
o download SE Toolkit
o check out top 3.5

These two excellent packages provide (in source) a lot of information on
the kvm and kstat functions.
Also, check the article

http://www.samag.com/documents/s=1323/sam0110a/0110a.htm
for more info on kstat.

Quote:

> The second question, and probably a more fundamemtal one is that, from
> what Ive heard from the SUN help desk, it isnt possible to work out
> the total amount of physical memory used by all processses on a
> system, even if I can figure out how much is being used by a given
> process, since there is no way to find out how much memory is shared
> between processes (e.g shared library). I was wondering if anyone from
> this NG can confirm this.
> If that is the case, that I guess I will have to make do with the sum
> of the amounts of memory each process occupies, which will somehow be
> larger than the actual amount of the physical memory being used.

> Any help will be much appreciated, TIA.

/Andreas

--
====================================================================
Andreas Almroth                           Phone/Fax +1-(917)-4218066

GPG fingerprint = 8E47 7EB6 0BEA 24AE EF96  7AA0 9AEF 78F2 92C1 7791