BCD 1 Report post Posted February 25, 2010 (edited) I need to know the CPU usage of a php script on gamma server which is currently being hosted on two servers. I can see the overall usage of the gamma server by going to stats in Cpanel (http://forums.xisto.com/no_longer_exists/). But it doesn't give me a clear picture of how much CPU resources is being used by my script as it fluctuates a lot because of others websites hosted on the server.Is there a way to know CPU usage of a single script? If its not possible on server, are there any alternate ways, may be php functions? Thanks for any help on this issue. Edited February 25, 2010 by BCD (see edit history) Share this post Link to post Share on other sites
truefusion 3 Report post Posted February 25, 2010 Every process has their own folder located in /proc. The directory name of the process is the same as the process's ID. In other words, let's say your script's process ID is 3, its process information would be located at /proc/3. However, Linux provides a directory known as "self." The self directory located at /proc/self is used to access the currently running program. This allows the program to obtain information about itself without having to know its process ID. I, however, do not know which file or directory you would have to read from in order to obtain the current CPU usage of the process, but this should provide some insight for you.Using PHP functions, i only know how to have PHP tell me how much memory it wasted and how long it took to execute the script. You can probably find a system tool that can retrieve the CPU usage by process ID and use exec() to retrieve the information from stdout, but i don't know what program exactly that would be. Share this post Link to post Share on other sites