How to get (Solaris 2.5.1): CPU load average, free VM, free physical memory

How to get (Solaris 2.5.1): CPU load average, free VM, free physical memory

Post by Gregory Touretsk » Fri, 09 Apr 1999 04:00:00

Hi all,

  I need to create an application that should check on some stage CPU load
average (what we can see from "uptime"), free and total virtual and physical
memory on the machine.

  This application should run on Solaris 2.5.1

   What I'd like to get is either recommendation of what system calls should
I use or pointer where I could find sources of uptime and/or vmtat :)

   Again, it can't be just perl script processing an output of regular
commands, but C-program...

Thanks in advance,
*   Gregory Touretsky    Tel: +972-4-865-6377 *
*  Intel Israel, Haifa   Fax: +972-4-865-5999 *



1. Load average and free memory in Unix C?

I'm compiling C on Sun 4,  Sun 5,  and HP Unix workstations.  

I'm struggling to find out how to do the following:
  1) Get the load average of the machine I'm on.
  2) Get the amount of free actual,  physical RAM I have on the machine.
  3) Get the amount of free swap space (virtual memory) I have on the

I've figured out that I can use rstat() in the RPC library to get the
load average of any machine on the net (and therefore could use it to
get the load average of my host machine),  but I was hoping someone would
have a better way of getting it for just the local (host) machine?  (And
by the way,  if anyone wants the C code showing how to use rstat() for
this purpose,  just ask.)

I'd like to be able to do all 3 of these things purely in C somehow without
resorting to system() calls and parsing output files of whatever unix
command I call inside of them.  There's got to be more elegant ways of
doing it.

Could anyone please give me some hints?

Thanks in advance,
  - Steve Weigand

2. Solaris and TOP

3. Free Virutal Memory is 1% even though Total Free Virtual Memory is above 1GB

4. Sun employees blogging about Solaris recently...

5. Solaris 2.4 panic: free: freeing free block

6. Hiding user processes. Edit kernel, libkvm?

7. load averages for CPU, memory, disk and network

8. Formatting a hard disk

9. Getting the total amount of free memory available under Unix Solaris 2.5

10. Getting free available memory using UCD SNMPD 4.2.6 on Solaris 9 SPARC

11. exchange free solaris 7 against free solaris 6

12. Relationship between load average and CPU busy or CPU idle

13. Getting free physical address space