LinuxQuestions.org
Visit Jeremy's Blog.
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 12-28-2011, 11:18 PM   #1
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467
Blog Entries: 60

Rep: Reputation: 51
getting system info across POSIX systems


From what I understand, in Linux it is possible to some basic system information in a struct via sysinfo(), but in some *nixs (like BSD) this call is not available. (sysctl() is used instead, from what I read). Has anyone written a lightweight C library that provides a sysinfo like abstraction across the various *nixes?
 
Old 12-31-2011, 03:13 PM   #2
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
If your system doesn't have proc file system installed set it up and you can access any system information you want and the kernel can offer.

Maybe you have to recompile your kernel with support for it.
 
Old 01-01-2012, 04:04 AM   #3
hydraMax
Member
 
Registered: Jul 2010
Location: Skynet
Distribution: Debian + Emacs
Posts: 467

Original Poster
Blog Entries: 60

Rep: Reputation: 51
I wasn't concerned about my system but everyone else's systems. Correct me if I'm wrong, but I was under the impression that not all Unixes use procfs the same way Linux does. (I.e., making all system information available through procfs.) And even if they did, I would still be interested in a cross-platform library that conveniently retrieves the information.
 
Old 01-01-2012, 10:39 AM   #4
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
You asked for posix conform platforms.
I can imagine that some systems like embedded or mobiles use kernels without support for it, also maybe high security systems.
But it is the users decision to use your software and use kernels with support for it.

Maybe this helps you - eache distro that has an instalation and setup system tool to support new installed Hardware, must have proc file system installed (suse - yast, ...).
Systems suppoting PNP hardware (USB, Bluetooth, WLAN, ...), too.
 
Old 01-01-2012, 10:52 AM   #5
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
Keep in mind that system specific things are provided through sysfs (/sys) since kernel-2.6
 
Old 01-01-2012, 01:21 PM   #6
tadeas
Member
 
Registered: Jul 2008
Location: Prague
Distribution: Opensuse
Posts: 40

Rep: Reputation: 5
In Python, there is psutil library that provides this info portably:
http://pypi.python.org/pypi/psutil

If you need C, you might check it's implementation, but I'm afraid that there are simply different implementations for different systems. On the other hand I believe that this is not difficult to do manually, get this info on all supported systems differently and wrap it in a single library.
 
Old 01-01-2012, 03:43 PM   #7
bastl
Member
 
Registered: Sep 2003
Location: Germany/BW
Distribution: My own
Posts: 237

Rep: Reputation: 22
About a library, KDE has a tool, kinfocenter, maybe it uses a library in c.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
getting cpu info, system info thru system calls naveenisback Programming 7 06-11-2010 02:06 PM
POSIX compliant distributed file systems without using shared storage anon.addon Linux - Software 1 12-12-2009 09:54 AM
Using AD on Windows 2008 Server to hold posix and netgroup info kenneho Linux - Server 2 10-15-2009 02:04 AM
How to build a C++ portable network application on Win32 and POSIX systems? Bassam Programming 1 05-17-2007 03:43 PM
Posix signals with info warrenpatrick Programming 2 11-24-2004 12:53 PM

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

All times are GMT -5. The time now is 08:17 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