LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 08-20-2004, 10:01 AM   #1
rags2k
LQ Newbie
 
Registered: Aug 2004
Posts: 7

Rep: Reputation: 0
how to determine cpu usage, memory usage, I/O usage by a particular user logged on li


Hello,

How can i collect statistics wrt amount of cpu used , amount of memory used, amouint of I/O done by a particular user logged into a linux system during a given time interval ?
How do i determine the amount of network traffic to/from a particular user logged in on a linux system?

thanks and regards
Raghu
 
Old 08-20-2004, 10:57 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 34
Get all of the pids for the user with
Code:
ps -ef | grep username
--then use the pid(s) in top
top p pid1 p pid2
 
Old 08-20-2004, 11:49 AM   #3
rags2k
LQ Newbie
 
Registered: Aug 2004
Posts: 7

Original Poster
Rep: Reputation: 0
I want to find the usage statistics for every user logged for every 5 minutes. Also I would prefer to write my code to determine instead of calling ps. CAn anyone show me the way here?

thanks and regards
Raghu
 
Old 08-20-2004, 12:55 PM   #4
Xagafinelle
LQ Newbie
 
Registered: Aug 2004
Distribution: SlackWare
Posts: 11

Rep: Reputation: 0
Well, there are a few things to consider...I mean, do you just want to write a shell-script, or do you want to actually write your own program, and what language?

If you are using C/C++ and libc, there are a few ways to do nearly what you want, but there is no magic function that will tell you what you want to know. The easiest ways is to read in the appropriate "files" in /proc. There's probably something much like you want in /proc/net, and also in /proc/sys/net, and other places. However, it's not a bad idea to just pipe to ps, since it's just scanning all of the processes that you're interested in anyway out of /proc, and then interpret the info it returns and format it for your own uses.

All of that should also be very straight forward. But no matter what you're going to have to do some scanning and formatting on your own to get the info you want.

--Xagafinelle
 
Old 08-21-2004, 04:45 AM   #5
rags2k
LQ Newbie
 
Registered: Aug 2004
Posts: 7

Original Poster
Rep: Reputation: 0
i want the updates for each user to be written to a separatye file so that when i do my periodic updating of my statlog database, i can update the values from the file to the databse. i dont mind how the stats end up i n the log file ie, whether by using C or shell script.pls let me know any way i can do this using C and libc as u mentioned.

thanks and regards
Raghu
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
getting realtime info on memory usage-cpu and harddrive usage steering Linux - Newbie 5 03-03-2005 08:43 PM
CPU and memory usage suguname Linux - Newbie 3 02-01-2005 01:45 PM
Controlling user memory/cpu usage JamesF1 Linux - General 0 10-19-2004 01:41 AM
Controlling CPU usage & memory usage Saravana babu Linux - Software 0 02-18-2004 05:55 AM
limiting cpu and memory usage by user process amitkush Linux - Security 2 07-04-2003 12:21 AM


All times are GMT -5. The time now is 01:58 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration