One particularly useful tool for systems administration is top. One thing you may not be aware of, is that you can output the information top provides to a file. You may also not know that you can run commands like this remotely via ssh. Here is a short script that demonstrates this:
#!/bin/sh /usr/bin/ssh user@domain.com "top b -n 1 > /tmp/topstats"; /usr/bin/scp user@domain.com:/tmp/topstats /tmp/topstats |
The b -n 1 is the number of iterations. If you use -n 3, you will get three different sets of stats. The default refresh is 5 seconds, so this would take 15 seconds for three iterations.
u-1@srv-1 stats $ ./gettop.sh topstats 100% |*****************************| 4241 00:00 |