Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Getting CPU, Memory, etc

Posted on 2001-08-21
5
Medium Priority
?
348 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

722 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