Simple tool to graph memory usage?

Solution 1:

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:

Because large portions of physical memory are typically shared among multiple applications, the standard measure of memory usage known as resident set size (RSS) will significantly overestimate memory usage. PSS instead measures each application's "fair share" of each shared area to give a realistic measure.

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):

  1. Show basic process information smem
  2. Show system view smem -R 4G -K /path/to/vmlinux -w
  3. Show totals and percentages smem -t -p
  4. Show different columns smem -c "name user pss"
  5. Show processes filtered by mapping smem -M libxml
  6. Show mappings filtered by process smem -m -P [e]volution
  7. Read data from capture tarball smem --source capture.tar.gz
  8. Show a bar chart labeled by pid smem --bar pid -c "pss uss"
  9. Show a pie chart of RSS labeled by name smem --pie name -s rss

You will, however, need a very recent kernel (> 2.6.27).

Solution 2:

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)

Solution 3:

Have a look at sarface - it depends on sar data, and you can monitor your memory usage (and all other sar/sysstat data) live.

Solution 4:

and what about collectd ?