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.
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:
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
SpideyModCommented:
per recommendation
SpideyMod
Community Support Moderator @Experts Exchange
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
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)