LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-31-2003, 04:30 AM   #1
grub
Member
 
Registered: Mar 2003
Location: Kurnool, India.
Distribution: Redhat 9
Posts: 67

Rep: Reputation: 15
Kernel statistics


Hi,
How to get the kernel statistics like no of active processess, total virtual memory size, no of hard disks used, etc.

grub
 
Old 03-31-2003, 04:36 AM   #2
iceman47
Senior Member
 
Registered: Oct 2002
Location: Belgium
Distribution: Debian, Free/OpenBSD
Posts: 1,123

Rep: Reputation: 47
you could use top to see stats and mount without any options to see mounted patitions
 
Old 03-31-2003, 04:47 AM   #3
grub
Member
 
Registered: Mar 2003
Location: Kurnool, India.
Distribution: Redhat 9
Posts: 67

Original Poster
Rep: Reputation: 15
top shows some required details. But this is not the problem. How can I get the statistics in my 'C' program. Is there any api to do the work.
 
Old 03-31-2003, 10:34 AM   #4
revrendi
LQ Newbie
 
Registered: Mar 2003
Location: California, USA
Distribution: Linux from Scratch
Posts: 9

Rep: Reputation: 0
Unfortunately, there's usually not a decent way to get that info through a clean API. The proc filesystem is there in part because of that shortcoming. If you take a look at the ps and top tools source you'll see that usually they just read the info out of a node somewhere under /proc and parse it. If you don't feel at all like learning about the format, there is the libgtop library from Gnome, http://www.gnome.org/softwaremap/projects/libgtop/. It's just a library that does that parsing for you. -- Rev
 
Old 03-31-2003, 09:53 PM   #5
grub
Member
 
Registered: Mar 2003
Location: Kurnool, India.
Distribution: Redhat 9
Posts: 67

Original Poster
Rep: Reputation: 15
Where can I get the virutal memory size (used and free), no of threads a process has created, state of the thread, no of ports used by a process, etc.
 
Old 03-31-2003, 10:19 PM   #6
revrendi
LQ Newbie
 
Registered: Mar 2003
Location: California, USA
Distribution: Linux from Scratch
Posts: 9

Rep: Reputation: 0
The memory info is in /proc/meminfo. There's an entry under /proc for each running process (and under Linux processes and threads are pretty much the same thing, a 'thread' is just a process which shares it's memory space with another process) that has more specific info. Sounds like most of the info you want is in /proc/$PID/status or from the directory /proc/$PID/fd. I believe you'll have to walk the process tree in order to figure out how many threads a process has created, and I'm not sure how to aggregate the processes into thread groups, although I assume the Tgid has something to do with it. I've never used libgtop, so I can't tell you what calls to use there. You'll have to check the docs or find some examples. Maybe someone who has used gtop will be kind enough to post a simple snippet. -- Rev
 
  


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
kernel fs statistics phoenix7 Programming 3 08-04-2005 01:39 AM
Statistics from stdin? edeca Linux - Software 0 05-23-2005 10:03 AM
counting statistics rafalek Linux - Networking 0 05-21-2004 03:39 PM
lm_sensros statistics JJX Linux - Newbie 0 04-24-2004 04:25 PM
statistics from the server eduac Linux - Networking 2 08-04-2003 09:03 PM

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

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