Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)

share

locked by HopelessN00b Dec 5 at 5:58

This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

13 Answers 13

Doesn't phpsysinfo give you the ability to see process info somehow?

share

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

share
1  
Yes, their suggestion that 2.6.27 is reasonably recent is pretty laughable. The only distros that I know that ship with a newer kernel are Fedora 10 and Ubuntu 9.01. –  Dave Cheney May 5 '09 at 15:09
    
9.04; Ubuntu 8.10 shipped with 2.6.27, but 2.6.30 is in rc3. –  jldugger May 5 '09 at 19:16
    
My apologies, I've spent to long in RHEL land, where 2.6.18 is considered recent. –  Dave Cheney Jun 12 '09 at 8:28

kSar, based on sar data, but it's java based, so is more or less platform independent and will allow you to ssh to a remote host to fetch the data.

http://ksar.atomique.net/

share

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)

share
1  
+1, I tought about that with google chart api. :) –  Node May 2 '09 at 14:27
    
good point. google chart api is probably quicker to work with... –  Mark Regensberg May 2 '09 at 14:29

I didn't get into more detail but collectl has an option for generating delimiter separated output so in the case of gnuplot, you just generate your data with spaces in it and you're all set. It even will load nicely into excel. If you want commas you can change the delimiter and if you really want to do the rrd route (just be careful because the plots do not necessary match the data!), you can change the delimeter to colons and even change the timestamps to UTC. -mark

share

You can use #top or #sysstat

share
  1. Grep the process(s).
  2. Parse the output and save in comma separated format in a text file.
  3. open the comma separated file in excel.
  4. Draw the graph for that data using the chart utility of excel.

If you want memory snapshots at different time interval... set the cron job at desired interval and run the script.

hope that helps....

share

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:

RECORD    1      cag-dl585-02     (1244758290.002) (Thu Jun 11 18:11:30 2009)

PROCESS SUMMARY (counters are /sec)
# PID  User     S VmSize  VmLck  VmRSS VmData  VmStk  VmExe  VmLib MajF MinF Command
 9089  root     S 66856K      0  2328K  1440K   212K   736K  6812K    0    0 sendmail:
 9097  smmsp    S 57600K      0  1772K  1304K   204K   736K  5904K    0    0 sendmail:
 9108  root     S  6428K      0   360K   180K    84K    88K  1944K    0    0 gpm
 9120  root     S 74808K      0  1136K   476K   520K    48K  1920K    0    0 crond
 9173  xfs      S 20904K      0  1828K  1124K    88K   104K  3084K    0    0 xfs

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

share

Do it yourself. Make a simple shell script updating RRD database. Then draw a graph using rrdtool.

share

and what about collectd ?

share

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

share

Hmm, the gnuplot FAQ says it doesn't support pie charts, but they suggest Bernhard Reiter's piechart.

share

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").

share

Not the answer you're looking for? Browse other questions tagged or ask your own question.