23

Is there a way for me to review cpu or memory usage on my ubuntu linux server? I've noticed my server (lamp set up) being slow at times, but by the time I log in as root and run a PS command, everything may have returned to normal.

It would be great to review a log of what resources different parts of the server consumed.

John
  • 7,153
  • 22
  • 61
  • 86

5 Answers5

16

Use dstat -ta --top-cpu

See: http://dag.wieers.com/home-made/dstat/

If you want to log to a file you can use:

dstat -ta --top-cpu --noheader --output systemstats.csv

Leon
  • 175
  • 1
  • 1
  • 6
Mircea Vutcovici
  • 16,706
  • 4
  • 52
  • 80
13

The sysstat collection of tools contains sar which is able to save system activity information: http://pagesperso-orange.fr/sebastien.godard/documentation.html

Dominik
  • 2,198
  • 13
  • 9
7

You could run MRTG to graph various aspects of the server, such as CPU usage, RAM usage, number of processes. It is very useful for servers without a GUI as it creates images for displaying on web pages.

If you have GNOME installed you can monitor system resources using the System Monitor application.

Alternatively you could run something like this every minute from cron:

top -n 1 -b | head >> logfile

which will log uptime, users, load averages, number of processes, CPU usage, memory/swap usage and the top three resource hungry processes into a file for viewing later. -n 1 runs top once

As you specifically mention you run Ubuntu I believe you can get this monitored by Canonical using Landscape.

JIm
  • 103
  • 2
Richard Holloway
  • 7,256
  • 2
  • 24
  • 30
2

Run sar in daemon mode. You can review a variety of information in detail after the fact. Try running sar in the foreground with something like 10 iterations over 10 seconds to get an idea what information is available.

BillThor
  • 27,354
  • 3
  • 35
  • 69
1

vmstat and iostat , mytop and apache top may also be help you pin point the bottleneck.

The Unix Janitor
  • 2,388
  • 14
  • 13