vancetech
asked on
How can I accurately graph the average CPU usage... not just load average?
I am writing a perl script that does some forking work, and I would like to monitor the loads of the computer running it. The load averages are typically around 3 - 6 over 1, 5, 15 minutes, but I seek more information than that.
I already watch the CPU usage on a 10 second interval, as presented by "ps -axo %cpu", but I don't think I am getting the whole picture.
When I use "top" it shows % User, % System, % Nice, % Interrupt, % Idle, but I don't think that "ps -axo %cpu" shows anything but the % User. How can I get a more accurate picture of how much load the system is under?
I haven't been able to find a perl module that does this.
Thank you.
I already watch the CPU usage on a 10 second interval, as presented by "ps -axo %cpu", but I don't think I am getting the whole picture.
When I use "top" it shows % User, % System, % Nice, % Interrupt, % Idle, but I don't think that "ps -axo %cpu" shows anything but the % User. How can I get a more accurate picture of how much load the system is under?
I haven't been able to find a perl module that does this.
Thank you.
There are multiple meanings for the phrase "how much load the system is under". Since it sounds like you're trying to get a more comprehensive picture rather than a single "number", you might like a utility like 'vmstat' or combine it with 'iostat'.
Within your application, you can use the 'times' operator to get information similar to what is reported by the command-line utility 'time'.
Within your application, you can use the 'times' operator to get information similar to what is reported by the command-line utility 'time'.
I have a suggestion for you.
Once you have chosen your metric, you could very easily write a perl script that call "top" periodically, pick up the relevant information and print it in a file. Say you chose, the "memory usage". You call top every second and pick up the "memory usage" of your script. Now print all this in a file.
After you are done with the script, you could use "gnuplot" to plot a graph of this data which gives you a broader picture or the trend of memory usage by your script.
Of course, once you have such a monitoring script in place, you could make it look for multiple parameters at a time.
Once you have chosen your metric, you could very easily write a perl script that call "top" periodically, pick up the relevant information and print it in a file. Say you chose, the "memory usage". You call top every second and pick up the "memory usage" of your script. Now print all this in a file.
After you are done with the script, you could use "gnuplot" to plot a graph of this data which gives you a broader picture or the trend of memory usage by your script.
Of course, once you have such a monitoring script in place, you could make it look for multiple parameters at a time.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Sorry I was not clear with my wordings, but that is exactly what I meant too!
Thanks for clarifying it stefan.
Thanks for clarifying it stefan.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
time perlscript