LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   how to determine cpu usage, memory usage, I/O usage by a particular user logged on li (http://www.linuxquestions.org/questions/programming-9/how-to-determine-cpu-usage-memory-usage-i-o-usage-by-a-particular-user-logged-on-li-220164/)

rags2k 08-20-2004 11:01 AM

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

jim mcnamara 08-20-2004 11:57 AM

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


rags2k 08-20-2004 12:49 PM

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

Xagafinelle 08-20-2004 01:55 PM

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

rags2k 08-21-2004 05:45 AM

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


All times are GMT -5. The time now is 05:39 PM.