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
Solved

Getting CPU, Memory, etc

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Title # Comments Views Activity
nodeip 9 86
UNiX Script filesystem space usage Part2 54 88
Image not there 4 56
capture vmstat info and insert it into an oracle table 31 34
Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

809 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