LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-04-2010, 09:34 PM   #1
chamila1986
Member
 
Registered: Oct 2009
Posts: 31

Rep: Reputation: 15
Question Getting System Information using C


I need to take system information like CPU speed,cache size,free and available physical and virtual memory etc in effective way. I tried to get it by reading the file /proc/cpuinfo and /proc/meminfo by using fread() and some string.h functions. But are there any functions or libraries or system calls exists in order to take these values directly and efficiently. Any idea please....
 
Old 01-05-2010, 03:22 AM   #2
MysticalGroovy
Member
 
Registered: Sep 2009
Location: Greece
Distribution: Slackware
Posts: 106

Rep: Reputation: 21
well in C++ I remember using system() to run a command, parse its output into a temp file and then reading the file. so simple

Code:
 system(cat /proc/meminfo >/tmp/tempFile);
 
Old 01-05-2010, 06:16 AM   #3
chamila1986
Member
 
Registered: Oct 2009
Posts: 31

Original Poster
Rep: Reputation: 15
You are correct sir...but as i feel is not efficient...


system(cat /proc/meminfo >/tmp/tempFile);

This involve reading /proc/meminfo, create /tmp/tempFile and write data from meminfo to tempFile etc...Isn't it too overhead to the system...can i grub current system information memory information,cpu utilisation from 'top' command(or any other command / structure like sysinfo() in kernal.h) and get it for my own program???? if so how...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find out indone information and datablocks information in a file system chaitanya1982 Linux - Newbie 1 09-24-2008 01:58 AM
how to know the system information thelonius Linux - General 4 03-23-2007 07:45 AM
system information tsitras Linux - Hardware 2 01-09-2006 08:30 PM
System Information RedHatCore Linux - Newbie 3 08-16-2005 02:19 PM
system information killi Linux - Hardware 2 05-10-2003 10:35 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration