Solved

Getting CPU, Memory, etc

Posted on 2001-08-21
5
334 Views
Last Modified: 2013-12-27
Hi experts,

  Does anyone know how can I get the CPU and Memory values from a Sparc with Solaris using C or C++? (Like SAR or perfmeter X Application)
  Do I need to open the kernel structure?
  How can I do that?
  I would appreciate C/C++ source code.

  Thanks in advance

  Leandro
0
Comment
Question by:leandro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 3

Expert Comment

by:interiot
ID: 6411390
I ran "truss uname -a" to watch what system calls it was making to determine the output of uname.  Turns out it calls sysinfo(2) several times.  The manpage is here:

    http://ist-socrates.berkeley.edu/cgi-bin/man.cgi?section=2&topic=sysinfo

And here's a code snippet I found elsewhere:

#include     <sys/systeminfo.h>
#include     <errno.h>
#include     <stdio.h>

#define     BUFF_SIZE     8192
main ()
{
     char     lBuff [BUFF_SIZE];

        long    lResult;
        errno   = 0;
        lResult = sysinfo (SI_ARCHITECTURE, lBuff, BUFF_SIZE);
        if (lResult != -1)
                 (void) printf ("sysinfo (SI_ARCHITECTURE)       = %s\\n", lBuff);
        else
                 (void) printf ("sysinfo (SI_ARCHITECTURE)       = -1, errno = %d\\n", lResult, errno);
}


There's also sysconf(3C):  http://www.bsn.com:8080/cgi-bin/htmlman?sysconf(3C)
0
 

Author Comment

by:leandro
ID: 6413250
This is not exactly I want.
I wanna get the CPU and Memory load values, ie, which CPU and Memory percentage are been used for my machine.
0
 

Expert Comment

by:smartino
ID: 6418321
Here is a link to the perfmeter source code. Maybe it can give you some hints.

"http://wuarchive.wustl.edu/graphics/graphics/packages/misc/?M=A"
0
 
LVL 21

Expert Comment

by:tfewster
ID: 8051569
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- PAQ & refund points

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8100173
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question