OProfile
OProfile
is a venerable tool for profiling everything that happens on a Linux server. You need to have debugging information for your kernel, which can be tricky to obtain depending on your distribution. But the basic data collection is simple after that, and contains everything from the OS to the highest level database operations.
OProfile
is the preferred tool for many who work on PostgreSQL to find bottlenecks and hotspots in the code under Linux. An excellent introduction to it that covers additional tools to extend its analysis power is available at http://wiki.postgresql.org/wiki/Profiling_with_OProfile.