How can I get CPU usage & mem usage in my program?

How can I get CPU usage & mem usage in my program?

Post by ronghua zhan » Tue, 06 Feb 2001 04:12:21



Does any body know how to get CPU usage and memory usage in program
under Solaris ? Any suggestion is appreciated!

ronghua

 
 
 

How can I get CPU usage & mem usage in my program?

Post by Paul Yanzic » Thu, 08 Feb 2001 21:46:42


I don't know about Solaris, but in Linux I would cat the files in the /proc
directory or use command line utilities and use fgets() and sscanf() to
parse them out to get the info that I want.

Paul


> Does any body know how to get CPU usage and memory usage in program
> under Solaris ? Any suggestion is appreciated!

> ronghua


 
 
 

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

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.

2. add partition to IDE without losing existing data

3. Seeing mem/cpu usage of separate programs?

4. Telnet für root-user

5. Quota-like limit on cpu-usage/memory-usage...

6. OpenBSD 3.1 console access via serial

7. System info (cpu usage, memory usage, etc) using SNMP?

8. Displaying X (GNOME) desktop via SSH on remote PC ...

9. How to get the usage of cpu and mem using syscall?

10. shell util for mem/cpu usage

11. Getting CPU usage in FreeBSD

12. Getting Idle or CPU usage?

13. Getting CPU usage info in C code on Solaris 7 - advice would be nice :-)