Portal Home > Knowledgebase > Articles Database > Is this a good way of calculating user's cpu and mem usage ?


Is this a good way of calculating user's cpu and mem usage ?




Posted by OpenInternet-Vince, 05-31-2010, 07:39 PM
I've written a script when is being run it will collect all the current processes being run by a specific user. Then the script will do a "ps" on the processes' to collect the %CPU and %MEM. Once those two variables has been collected. The script will then add up all numbers then divided by the total number of processes during the runtime. This will calculate the average usage of all the processes. But I'm not sure if it is accurate as to the actual server's memory and cpu for that user. Any thoughts ?

Posted by Jacob Wall, 05-31-2010, 08:22 PM
IMO that's a good way to catch abusive users(ie port scanning, etc) but not for server memory/cpu usage. You can create a script, like this: http://img408.imageshack.us/img408/2...00531at723.png http://img696.imageshack.us/img696/2...00531at723.png

Posted by OpenInternet-Vince, 05-31-2010, 10:47 PM
From what I've been researching. It is very hard to find the actual memory usage on linux because of all the libraries that it needs. What about CPU usage ? Is the CPU usage inaccurate as well because of depended libraries ?

Posted by Jacob Wall, 05-31-2010, 10:50 PM
It's very easy to get the actual memory usage, just remember you have to less the cached ram(Since the image shows OVZ VMs you don't have to do that). I'm not sure where you're getting the library stuff from, care to shed some light?

Posted by OpenInternet-Vince, 05-31-2010, 11:22 PM
Well, if you do a pmap on a process. You can see each library's memory usage.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
preg_match help (Views: 489)