Solved

Getting CPU, Memory, etc

Posted on 2001-08-21
5
327 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
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 20

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

785 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