Is there a script that will show memory usage as a graph, for example as a pie-chart, with each process being being a separate slice?
I'm not looking for something like Munin to graph memory usage over time, but rather show the memory usage per-process at a single point in time.
To make my request even more obscure, it is for a headless server (so no X applications). The simplest way would be to write a PNG file, or possibly an HTML file (which could use Javascript to allow the filtering of processes, changing between graph-types and so on)
Per process memory accounting is tricky for a number of reasons I'll get into in a minute. For simple monitoring, gkrellmd, or nagios scripts is probably enough. If you want greater accuracy, you'll need to look harder.
smem introduces the concept of Proportional Set Size:
Example: You start up GNOME, causing a number of processes to start, one for each applet and program. They all link to libglib. Linux loads libglib into one block of memory and maps it into every process that wants libglib. Naive memory accounting counts the full libglib size against every process linking to it.
smem divides up the cost of libglib among the processes using it, to give a closer picture of reality. It also has a number of options to display memory usage (from website):
You will, however, need a very recent kernel (> 2.6.27).
Can't think of anything off the shelf
however, a combo of a PHP script exec'ing ps -AH v | awk '{ print $8,$9,$10}' and using that with pChart could give you a web page that would do what you are looking for? (usage in Kb, percentage of total and process name)
Have a look at sarface - it depends on sar data, and you can monitor your memory usage (and all other sar/sysstat data) live.
and what about collectd ?
Do it yourself. Make a simple shell script updating RRD database. Then draw a graph using rrdtool.
If you're really into lower levels of detail, don't forget collectl. Here's an example of the types of per process memory utilization it can report:
If you're interested in specific processes you can specify appropriate filters (including a switch to show threads).
And if you interested in memory in general it also can show slab detail and even has a vmstat format output. Why would you want to show data in vmstat format when the existing tool already does that? That's easy - with collectly you can log stats to a file and play it back later in multiple formats.
try it, you'll like it
If you want memory snapshots at different time interval... set the cron job at desired interval and run the script.
hope that helps....
This isn't exactly what you're looking for, but perhaps you can adapt it to your needs using this reference (look for "Per Process Memory Usage").
Hmm, the gnuplot FAQ says it doesn't support pie charts, but they suggest Bernhard Reiter's piechart.
You can use #top or #sysstat